Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* average using a function */
- #include<conio.h>
- #include<stdio.h>
- void main()
- {
- float avg(float[]);
- float a[5]={12.5,11.5,13.5,15.2,20.5};
- float average;
- clrscr();
- average=avg(a);
- printf("Average of 5 numbers is %f",average);
- getch();
- }
- float avg(float a[5])
- {
- int i;
- float sum=0;
- for(i=0;i<5;i++)
- {
- sum=sum+a[i];
- }
- return (sum/5);
- }
Advertisement
Add Comment
Please, Sign In to add comment