63 095
Assignments Done
99%
Successfully Done
In July 2018

Answer to Question #57079 in C++ for yaseen

Question #57079
) Write a pseudocode that calculates and prints the average of
several integers. Assume the last value read with scanf is the sentinel 9999. A typical input sequence
might be
10 8 11 7 9 9999
indicating that the average of all the values preceding 9999 is to be calculated.
Expert's answer
Solution
Declare a as integer
Declare sum as real
Declare avg as real
Declare n as integer
Let n=0
Let sum=0
Print ‘Input set of numbers, 9999 for end of sequence ’

repeat
Input a
if a≠9999 then
Let n=n+1
Les sum=sum+a
end if
until a≠9999

if n≠0 then
avg=sum/n
Print ‘Average is ’, avg
Else
Print ‘Sequence is empty’
End if

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions