Friday, August 29, 2014

Create a program that prompts a user to input five integers. The program then displays the sum and average values of its integers


Code

#include<stdio.h>
int main()
{
int a,b,c,d,e,avg,sum;

printf ("Enter five integers: ");
scanf ("%d%d%d%d%d",&a,&b,&c,&d,&e);

sum = (a+b+c+d+e);

avg = (sum / 5);

printf ("SUM = %d \n\n AVG = %d\n",sum,avg);

printf ("\nPress any key to close.");

getch ();
return 0;
}

Output

C program average

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact