write a program in qbasic to find the sum of any 10 numbers. ( use counter and accumulator )
Answers
Answered by
26
dont know QBASIC but heres a simple algorithm
declare a variable s
FOR i = 1 TO 10
input a num from user
s=s+num
NEXT i
PRINT (Print the value of s)
that will surely work.
declare a variable s
FOR i = 1 TO 10
input a num from user
s=s+num
NEXT i
PRINT (Print the value of s)
that will surely work.
Answered by
17
CLS //start of the program
I=1 //initializing I
DO //loop starts
PRINT I // prints value of i
SUM = SUM + I //formula to produce sum (initial value of sum=0)
I=I+1 //Incrementing value of I
LOOP WHILE I<=10 //Loop condition and loop exit
PRINT "Sum=" ; SUM // prints the sum
END //end of the program
Attachments:
Similar questions
Math,
7 months ago
Math,
7 months ago
Math,
1 year ago
Political Science,
1 year ago
Psychology,
1 year ago
Physics,
1 year ago