Advertisement
PROFESSOR_AIH

Column in Array

Apr 19th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     double arr[12][12],sum=0.0;
  5.     int n,j,i;
  6.     char ch;
  7.     scanf("%d %c",&n,&ch);
  8.     for(i=0; i<12; i++)
  9.     {
  10.         for(j=0; j<12; j++)
  11.         {
  12.             scanf("%lf",&arr[i][j]);
  13.         }
  14.     }
  15.     for(j=0; j<12; j++)
  16.     {
  17.         sum=sum+arr[j][n];
  18.     }
  19.     if(ch=='S')
  20.         printf("%.1lf\n",sum);
  21.     else if(ch=='M')
  22.         printf("%.1lf\n",(sum/12.0));
  23.  
  24.     return 0;
  25. }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement