Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Specifer



" ; " after loop



Header file



Test expression



Working with switch case




Array_sum and mean of N numbers




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int i,n,arr[100],sum=0; float mean=0.0; pf("Enter the size of the array: "); scanf("%d",&n); //taking array element pf("\nEnter the element of the array: "); for(i=0;i < n;i++) { scanf("%d",&arr[i]); //adding every element and assigning in sum variable sum+=arr[i]; } /* the sum is typecast from integer to float to get exact output and then average is calculating */ mean=(float)sum/n; //printing the output pf("\nThe summation of the given number = %d",sum); pf("\nThe average of the given number = %.2f",mean); return 0; }
OUTPUT:


© 2018 - All rights reserved