Wednesday, October 16, 2019

76. Qbasic program to input number and check whether the given no. Composite or not.


76.      Write a sub program to input number and check whether the given no. Composite or not.

DECLARE SUB COMPOSITE (N)
INPUT "ENTER ANY NUMBER"; N
CALL COMPOSITE (N)
END

SUB COMPOSITE (N)
C = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN C = C + 1
NEXT I
IF C < > 2 THEN
PRINT N; "IS COMPOSITE NUMBER"
ELSE
PRINT N; "IS NOT COMPOSITE NUMBER"
END IF
END SUB

No comments:

Post a Comment