Write a program to find the sum of only even factor of any number in qbasic
Please do it fast
Answers
Answered by
2
Answer:
This is the required QBASIC program for the question.
10 CLS
20 INPUT "Enter a number: "; A
30 PRINT "Even factor(s) are as follows.."
40 FOR i = 2 TO A STEP 2
50 IF A MOD i = 0 THEN PRINT i;
60 NEXT i
70 END
Explanation:
- As we have to find out the sum of even factors, so, the loop iterates in the range 2 to N (number). Step value is 2 as we have to skip the odd factors. Then, if the value of the loop variable divides the number completely, then we will add that value to sum. At last, sum is displayed.
Refer to the attachment.
Attachments:
Similar questions