Computer Science, asked by navnathdudhate3449, 10 months ago

Write a program to find the average of five numbers in qbasic

Answers

Answered by BrainlyTech
4

\textbf{ Program }

CLS

print "a program to calculate the average of a number"

DIM NUM(1 TO 5) AS INTEGER

FOR I = 1 TO 5

   INPUT "ENTER A NUMBER ", NUM(I)

NEXT I

PRINT "YOU HAVE INSERTED THESE VALUES"

FOR J = 1 TO 5

   PRINT NUM(J)

NEXT J

LET SUM = 0

FOR K = 1 TO 5

   LET SUM = SUM + NUM(K)

NEXT K

PRINT "TOTAL SUM IS", SUM

LET AV = SUM / 5

PRINT "THE AVERAGE IS", AV

PRINT "HERE IS THE GUIDE"

PRINT "CALCULATE ALL THE ELEMENT TOGETHER AND DIVIDE BY THE TOTAL COUNT"

PRINT "IF YOU INSERT 1,2,3, YOU WILL ADD 1 + 2 + 3 = 6, THEN DIVIDE 6 BY 3 = 2"

PRINT "HERE IS THE SOLUTION AGAIN"

LET SUM = 0

FOR K = 1 TO 5

   LET SUM = SUM + NUM(K)

NEXT K

PRINT "TOTAL SUM IS", SUM

LET AV = SUM / 5

PRINT "THE AVERAGE IS", AV

END

Answered by TalentedLady
11

\LARGE\sf {\underline{\underline\green{Required \:  Answer:-}}}

Program

CLS

print "a program to calculate the average of a number"

DIM NUM(1 TO 5) AS INTEGER

FOR I = 1 TO 5

INPUT "ENTER A NUMBER ", NUM(I)

NEXT I

PRINT "YOU HAVE INSERTED THESE VALUES"

FOR J = 1 TO 5

PRINT NUM(J)

NEXT J

LET SUM = 0

FOR K = 1 TO 5

LET SUM = SUM + NUM(K)

NEXT K

PRINT "TOTAL SUM IS", SUM

LET AV = SUM / 5

PRINT "THE AVERAGE IS", AV

PRINT "HERE IS THE GUIDE"

PRINT "CALCULATE ALL THE ELEMENT TOGETHER AND DIVIDE BY THE TOTAL COUNT"

PRINT "IF YOU INSERT 1,2,3, YOU WILL ADD 1 + 2 + 3 = 6, THEN DIVIDE 6 BY 3 = 2"

PRINT "HERE IS THE SOLUTION AGAIN"

LET SUM = 0

FOR K = 1 TO 5

LET SUM = SUM + NUM(K)

NEXT K

PRINT "TOTAL SUM IS", SUM

LET AV = SUM / 5

PRINT "THE AVERAGE IS", AV

END

Similar questions