QBASIC PROGRAM TO FIND SQUARE OF ODD DIGITS OF A NUMBER
CLS
INPUT ENTER ANY NUMBER; N
PRINT "SQUARE OF ODD DIGITS ARE ";
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN PRINT R ^ 2;
N = N \ 10
WEND
END
USING SUB
DECLARE SUB SQO(N)
CLS
INPUT ENTER ANY NUMBER; N
CALL SQO(N)
END
SUB SQO(N)
PRINT "SQUARE OF ODD DIGITS ARE ";
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN PRINT R ^ 2;
N = N \ 10
WEND
END SUB
0 Comments