Write a program to print the sum of numbers between 100 and 200 in qbasic
Answers
Answered by
2
Answer:
This is the required QBASIC program for the question.
CLS
S = 0
FOR I = 101 TO 199
S = S + I
NEXT I
PRINT "SUM: "; S
END
Algorithm:
- START.
- Initialise S = 0
- Iterate through numbers in the range 101 to 199.
- Add the numbers and store them in S.
- Display the value of S.
- STOP.
Refer to the attachment.
•••♪
Attachments:
Answered by
3
10 For x = 12 to 48 step 2
20 Y = Y + x
30 Next x
40 print Y
If you wanted to include 10 and 50 change line 10 (This is written in BASIC not QBASIC as I learnt BASIC 40 years ago but the logic should be the same)
Similar questions