Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Specifer



Comment



Iterative statement



Test expression



" ; " after loop




Average of given input



// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int n,m,j,sum=0; float ave; //taking the number to continue loop pf("Enter any integer number: "); scanf("%d",&n); for(j=1;j<=n;j++) { pf("\nEnter the number %d => ",j); //taking input scanf("%d",&m); sum+=m; //every given input number is adding with sum } ave=(float)sum/n; //sum is typecast to float pf("\nThe average of given number is : %f",ave); return 0; }
OUTPUT:


© 2018 - All rights reserved