Array Sum Avg - //find largest int big=a[0];...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//This program finds sum+avg using arrays #include <stdio.h> void main() { int a[5],i; //load from keyboard for(i=0;i<5;i++) { printf("Enter a number "); scanf("%d",&a[i]); } //print array for(i=0;i<5;i++) printf("%d ",a[i]); printf("\n\n"); //sum+avg array int sum=0; for (i=0;i<5;i++) sum+=a[i]; float avg; avg=sum/(float)5; printf("Sum is %d Avg is %f\n",sum,avg);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //find largest int big=a[0]; for(i=1;i&lt;5;i++) if(a[i]&gt;big) big=a[i]; printf(&quot;Largest is %d\n&quot;,big); } /* Enter a number 45 Enter a number 62 Enter a number 16 Enter a number 15 Enter a number 616 45 62 16 15 616 Sum is 754 Avg is 150.800003 Largest is 616 Press any key to continue . . . */...
View Full Document

Ask a homework question - tutors are online