Answer to Question #288154 in C for Freddie

Question #288154

Write a program to prompt the user to enter five numbers. The program then stores numbers in an array, compute and output the sum and average.

1
Expert's answer
2022-01-17T08:25:23-0500
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
/*
	Write a program to prompt the user to enter five numbers. 
	The program then stores numbers in an array, compute and output the sum and average.
*/


#define MAX_SIZE 5
int main()
{
	float Num[MAX_SIZE],Sum=0,Avg=0;
	int n;
	
	for(n=0;n<MAX_SIZE;n++)
	{
		printf("\n\tEnter No. %d: ",n+1); scanf("%f",&Num[n]);
		Sum = Sum + Num[n];
	}
	Avg = Sum/MAX_SIZE;
	
	printf("\n\tInput Numbers: ");
	for(n=0;n<MAX_SIZE;n++) printf("%.1f, ",Num[n]);
	printf("\n\tSum = %.2f",Sum);
	printf("\n\tAverage = %.2f",Avg);
	return(0);	
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS