Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Working with switch case



Test expression



Iterative statement



Specifer




Function_ average of given input




// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h> #include<math.h> #define pf printf //function declaration float fact(int); void main() { int a; float total,total1; printf("Enter any number: "); scanf("%d",&a); //function call total=fact(a); printf("\nAVERAGE= %.2f",total); return 0; } //function definition float fact(int n) //function header //function body { int i,m,sum=0; float ave; for(i=1;i<=n;i++) { printf("\nEnter the value no. #%d: ",i); scanf("%d",&m); sum+=m; //summation of total number ave=(float)sum/(float)n; } return ave; }
OUTPUT:


© 2018 - All rights reserved