Create an algorithm that will accept 4 numbers and display the sum and average.Draw a flowchart.
FLOWCHART:
ALGORITHM:
1) Start
2) Let sum=0, avg=0
3) Now read input numbers from user and add them to sum
for(i=1;i<=4;i++)
{
read num
sum=sum+num
}
4) Calculate average using sum
avg=sum/4
5) Print sum and avg
6) Stop
SUMMARY:
The above flowchart and algorithm shows the sum and average calculation of the 4 numbers read from the user. We first declare variable sum and avg and initialize them to 0. Then we iterate loop to 4, read number and calculate sum as well. After sum is calculated we find average of the sum/total_numbers (4 in this case).
Note: If you have any queries than let me know in the comments. If you find it helpful than a Like would be appreciated.
Get Answers For Free
Most questions answered within 1 hours.