Assignment for class IX (part iii)

WAP to enter any number and display:

          
1.    To reverse the given digits.
 Ans à
REM
CLS
S=0
INPUT “Enter a number”; N
WHILE N<>0
R=N MOD 10
S=S * 10 + R
N=N\10
WEND
PRINT “The reverse number is”; S
END
2.     To display product of entered digits.
 Ans à
REM
CLS
P=1
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
P= P *R
N= N\10
WEND
PRINT “THE PRODUCT OF ENTERED DIGITS IS”; P
END
3.    To display product of even digits.
 Ans à
REM
CLS
P=1
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
IF R MOD 2=0 THEN P= P*R
N=N\10
WEND
PRINT “THE PRODUCT OF EVEN DIGITS IS”; P
END
4.    To display product of odd digits.
 Ans à
REM
CLS
P=1
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
IF R MOD 2=1 THEN P= P*R
N=N\10
WEND
PRINT “THE PRODUCT OF ODD DIGITS IS”; P
END
5.    To count total number of entered digits.
 Ans à
REM
CLS
S=0
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
S= S+1
N=N\10
WEND
PRINT “THE TOTAL NUMBER OF DIGITS IS”; S
END 
6.    To count total number of odd digits.
 Ans à
REM
CLS
S=0
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
IF R MOD 2 = 0 THEN S = S+1
N= N\10
WEND
PRINT “THE TOTAL NUMBER OF EVEN DIGITS IS”; S
END
7.    To count total number of odd digits.
 Ans à
REM
CLS
S=0
INPUT “ENTER A NUMBER”; N
WHILE N<>0
R= N MOD 10
IF R MOD 2 = 1 THEN S = S+1
N= N\10
WEND
PRINT “THE TOTAL NUMBER OF ODD DIGITS IS”; S
END
8.    To check whether the given number is Palindrome or not.
 Ans à
REM
CLS
S=0
INPUT “ENTER A NUMBER”; N
A=N
WHILE N<>0
R= N MOD 10
S= S * 10 + R
N= N\10
WEND
IF A=S THEN
PRINT “THE GIVEN NUMBER IS PALINDROME”
ELSE
PRINT “THE GIVEN NUMBER IS NOT PALINDROME”
END IF
END
9.    To check whether the given number is Armstrong or not. 
 Ans à
REM
CLS
S=0
INPUT “ENTER ANY NUMBER”; N
A=N
WHILE N <>0 
R= N MOD 10
S=S+R^3
N=N\10
WEND
IF A = S THEN
PRINT “THE GIVEN NUMBER IS ARMSTRONG”
ELSE
PRINT “THE GIVEN NUMBER IS NOT ARMSTRONG”
END IF
END

Comments

Popular posts from this blog

MADAM CURIE

Assignment for class IX (part ii)