But if anyone wants to input value themslves then scanf can be used. The main source code of this programme is:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
float average(float a[]); | |
int main() | |
{ | |
float num[]={2.6,3.4,8.4,2.2,6.3}; | |
float avg; | |
avg=average(num); | |
printf("average of values in array=%f",avg); | |
getch(); | |
} | |
float average(float a[]) | |
{ | |
int i; | |
float sum,avg; | |
sum=0; | |
for(i=0;i<5;i++) | |
{ | |
sum=sum+a[i]; | |
} | |
avg=sum/5; | |
return avg;} |
0 comments :
Post a Comment