PROGRAM BY SUB AND FUNCTION PROCEDURE
- WAP TO FIND SUM OF DIGIT
=> DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
S=S+R
N=N \ 10
WEND
PRINT" SUM OF DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
=>DECLARE SUB SUM(N)
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
S=S+R
N=N \ 10
WEND
PRINT" SUM OF DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
- WAP FIND THE SQUARE OF DIGIT
=>DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
S= S+R^2
N= N\10
WEND
PRINT" SUM OF SQUARE DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT " ENTER ANY NUMBER ";N
PRINT " SUM OF SQUARE OF DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R^2
N = N\10
WEND
SUM = S
END FUNCTION
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
S= S+R^2
N= N\10
WEND
PRINT" SUM OF SQUARE DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT " ENTER ANY NUMBER ";N
PRINT " SUM OF SQUARE OF DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R^2
N = N\10
WEND
SUM = S
END FUNCTION
- WAP FIND THE CUBE OF DIGIT
=>DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
S= S+R^3
N= N\10
WEND
PRINT"SUM OF CUBE OF DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT " ENTER ANY NUMBER ";N
PRINT " SUM OF CUBE OF DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R^2
N = N\10
WEND
SUM =S
END FUNCTION
- WAP TO REVERSE THE DIGIT
CLS
INPUT" ENTER ANY NUMBER";N
CALL REV(N)
END
SUB REV(N)
S=0
WHILE N<>0
R=N MOD 10
S=S*10+R
N= N\10
WEND
PRINT " REVERSED DIGIT=";S
END SUB
=> DECLARE FUNCTION REV(N)
CLS
INPUT" ENTER ANY NUMBER";N
PRINT "REVERSED DIGIT=";REV(N)
END
FUNCTION REV(N)
S=0
WHILE N<>0
R=N MOD 10
S=S*10+R
N= N\10
WEND
REV=S
END FUNCTION
- WAP TO CHECK WHETHER THE GIVEN NUMBER IS PALLINDROME OR NOT.
=> DECLARE SUB PAL(N)CLS
INPUT" ENTER ANY NUMBRE";N
CALL PAL(N)
END
SUB PAL(N)
A=N
S=O
WHILE N<>0
R= N MOD 10
S=S*10 +R
N =N\10
WEND
IF S=A THEN
PRINT " THE NUMBER IS PALLINDROME"
ELSE
PRINT" THE NUMBER IS NOT PALLINDROME"
END IF
END SUB
=>DECLARE FUNCTION PAL(N)
CLS
INPUT" ENTER ANY NUMBER";N
A=N
IF A=PAL(N) THEN
PRINT" ENTER ANY NUMBER IS PALLINDROME;
ELSE
PRINT"THE NUMBER IS NOT PALLINDROME"
END
FUNCTION PAL(N)
S=0
WHILE<>0
R=N MOD 10
S=S*10+R
N=N\10
WEND
PAL=S
END FUNCTION
- WAP TO CHECK WHETHER THE GIVEN NUMBER IS ARMSTRONG OR NOT.
=> DECLARE SUB ARM (N)
CLS
INPUT" ENTER ANY NUMBRE";N
CALL ARM(N)
END
SUB ARM(N)
S=O
A=N
WHILE N<>0
R= N MOD 10
S=S +R^3
N= N\10
WEND
IF A=S THEN
PRINT " THE NUMBER IS ARMSTRONG"
ELSE
PRINT" THE NUMBER IS NOT ARMSTRONG"
END IF
END SUB
PRINT " THE NUMBER IS ARMSTRONG"
ELSE
PRINT" THE NUMBER IS NOT ARMSTRONG"
END IF
END
FUNCTION ARM(N)S=0WHILE<>0R=N MOD 10S=S+R^3N=N\10WENDARM=SEND FUNCTION
- WAP TO FIND THE SUM OF EVEN DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
IF R MOD 2=0 THEN S=S+R
N=N \ 10
WEND
PRINT" SUM OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE SUMOF ODD DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
IF R MOD 2=0 THEN S=S+R
N=N \ 10
WEND
PRINT" SUM OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE SUMOF ODD DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
IF R MOD 2=1 THEN S=S+R
N=N \ 10
WEND
PRINT" SUM OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10\
IF R MOD 2=1 THEN S=S+R
N=N \ 10
WEND
PRINT" SUM OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE SUM OF SQUARE OF EVEN DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=0 THEN S=S+R^2
N=N \ 10
WEND
PRINT" SUM OF SQUARE OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF SQUARE OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R^2
N=N\10
WEND
SUM=S
END FUNCTION
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=0 THEN S=S+R^2
IF R MOD 2=0 THEN S=S+R^2
N=N \ 10
WEND
PRINT" SUM OF SQUARE OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF SQUARE OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R^2
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE SQUAREOF ODD DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=1 THEN S=S+R^2
N=N \ 10
WEND
PRINT" SUM OF SQUARE OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF SQUARE OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R^2
N=N\10
WEND
SUM=S
END FUNCTION
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=1 THEN S=S+R^2
N=N \ 10
WEND
PRINT" SUM OF SQUARE OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF SQUARE OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R^2
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE SUM OF CUBE OF EVEN DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=0 THEN S=S+R^3
N=N \ 10
WEND
PRINT" SUM OF CUBE OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF CUBE OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R^3
N=N\10
WEND
SUM=S
END FUNCTION
INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=0 THEN S=S+R^3
N=N \ 10
WEND
PRINT" SUM OF CUBE OF EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF CUBE OF EVEN DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= O THEN S=S+R^3
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO FIND THE CUBE OF ODD DIGIT ONLY
=> DECLARE SUB SUM(N)
CLS INPUT" ENTER ANY NUMBER ";N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=1 THEN S=S+R^3
N=N \ 10
WEND
PRINT" SUM OF CUBE OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF CUBE OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R^3
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO COUNT TOTAL DIGIT
=>DECLARE SUM OF TOT(N)
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
S=S+1
N=N\10
WEND
PRINT "TOTAL DIGIT=";S
END SUB
=>DECLARE FUNCTION TOT(N)
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
S=S+1
N=N\10
WEND
TOT=S
END FUNCTION
- WAP TO COUNT TOTAL EVEN DIGIT
=>DECLARE SUM OF TOT(N)
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=0 THEN S=S+1
N=N\10
WEND
PRINT "TOTAL EVEN DIGIT=";S
END SUB
=>DECLARE FUNCTION TOT(N)
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL EVEN DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=0 THEN S=S+1
N=N\10
WEND
TOT=S
END FUNCTION
- WAP TO COUNT TOTAL ODD DIGIT
=>DECLARE SUM OF TOT(N)
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=1 THEN S=S+1
N=N\10
WEND
PRINT "TOTAL ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION TOT(N)
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL ODD DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=1 THEN S=S+1
N=N\10
WEND
TOT=S
END FUNCTION
SUB SUM(N)
S=0
WHILE N<>0
R= N MOD 10
IF R MOD 2=1 THEN S=S+R^3
N=N \ 10
WEND
PRINT" SUM OF CUBE OF ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION SUM(N)
CLS
INPUT" ENTER ANY NUMBER ";N
PRINT" SUM OF CUBE OF ODD DIGIT=";SUM(N)
END
FUNCTION SUM(N)
S=0
WHILE N<>O
R=N MOD 10
IF R MOD 2= 1 THEN S=S+R^3
N=N\10
WEND
SUM=S
END FUNCTION
- WAP TO COUNT TOTAL DIGIT
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
R=R MOD 10
S=S+1
N=N\10
WEND
PRINT "TOTAL DIGIT=";S
END SUB
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
S=S+1
N=N\10
WEND
TOT=S
END FUNCTION
- WAP TO COUNT TOTAL EVEN DIGIT
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
R=R MOD 10
IF R MOD 2=0 THEN S=S+1
N=N\10
WEND
PRINT "TOTAL EVEN DIGIT=";S
END SUB
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL EVEN DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=0 THEN S=S+1
N=N\10
WEND
TOT=S
END FUNCTION
- WAP TO COUNT TOTAL ODD DIGIT =>DECLARE SUM OF TOT(N)
CLS
INPUT"ENTER ANY NUMBER";N
CALL TOT(N)
END
SUB TOT(N)
S=0
WHILE N<>0
R=R MOD 10
R=R MOD 10
IF R MOD 2=1 THEN S=S+1
N=N\10
WEND
PRINT "TOTAL ODD DIGIT=";S
END SUB
=>DECLARE FUNCTION TOT(N)
CLS
INPUT" ENTER ANY NUMBER";N
PRINT"TOTAL ODD DIGIT=";TOT(N)
END
FUNCTION TOT(N)
S=0
WHILE N<>0
R=R MOD 10
IF R MOD 2=1 THEN S=S+1
N=N\10
WEND
TOT=S
END FUNCTION