Monday, September 30, 2019

Write a Qbasic Program to find the sum of square of odd digits using function procedure.

Ashoj 13 - Program 05
Write a Qbasic Program to find the sum of square of odd digits using function procedure.


DECLARE FUNCTION SUMODD (N)
CLS
INPUT "ENTER ANY NUMBER"; N
SU = SUMODD (N)
PRINT "SUM OF SQUARE OF ODD DIGITS"; SU
END
FUNCTION SUMODD (N)
S = 0
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN S = S + R ^ 2
N = N \ 10
WEND


SUMODD = S
END FUNCTION

No comments:

Post a Comment