Computer Science, asked by sumitchatterjee288, 6 months ago

write a programme in QBASIC to display the sum of the first 10 terms of the following series
a) S=7+11+15+19+........
b)S=88+ 86 + 84........​

Answers

Answered by Anonymous
4

Answer:

10 REM ‘Program to find the sum of of even numbers between 10 and 50’

20 CLS

30 LET s = 10

40 FOR i = 10 TO 50 STEP 2

50 LET s = s + i

60 NEXT i

70 PRINT "The sum of the numbers is "; s

80 END

Now, this is an easy example, and should produce a string of even numbers of the simplest sort.

For sophistication, we can add this :

10 REM ‘Program to find the sum of of even numbers between 10 and 50’

15 REM ‘Using i MOD 2 form’

20 CLS

30 LET s = 10

40 FOR i = s TO 50

50 IF i MOD 2 =0 THEN LET s = s + i

60 NEXT i

70 PRINT "The sum of the numbers is "; s

80 END

Where the Modulus (MOD) of 2 for even numbers is used to return a more precise result. Also, we can modify value s to whatever we want.

We can get even more sophisticated by putting in INPUT statements to take in user inputs for variables s and i . And so on.

Some references for you :

I must beg your pardon for using line numbers and bold text statements. Its just to show that at 40 years old I am a programming old codger, as I grew up programming Z80-class 8bit home computers like 1K RAM ZX-81’s, and 8088 1MB XT PC’s and GW-Basic !

Similar questions