Computer Science, asked by chaudhurytapasi1984, 1 month ago

WAP to input a number and find the addition of its odd factors in q basic.​

Answers

Answered by TrishnaMandal
1

Answer:

131. WAP to input any number and display the factors.

CLS

INPUT "ENTER ANY NUMBER"; N

PRINT "FACTORS OF"; N; "=";

FOR I = 1 TO N

IF N MOD I = 0 THEN PRINT I;

NEXT I

END

USING SUB PROCEDURE

DECLARE SUB FACT (N)

CLS

INPUT "ENTER ANY NUMBER"; N

CALL FACT (N)

END

SUB FACT (N)

PRINT "FACTORS OF"; N; "=";

FOR I = 1 TO N

IF N MOD I = 0 THEN PRINT I;

NEXT I

END SUB

132. WAP to input any number and display the prime factors.

CLS

INPUT "ENTER ANY NUMBER"; N

PRINT "PRIME FACTORS OF"; N; "=";

FOR I = 1 TO N

C = 0

FOR J = 1 TO I

IF I MOD J = 0 THEN C = C + 1

NEXT J

IF N MOD I = 0 AND C = 2 THEN PRINT I;

NEXT I

END

USING SUB PROCEDURE

DECLARE SUB FACT (N)

CLS

INPUT "ENTER ANY NUMBER"; N

CALL FACT (N)

END

Similar questions