mohas8

dimensional

Sep 28th, 2022
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. const int ROW = 4;
  3. const int COLUMN = 4;
  4.  
  5. int main()
  6. {
  7.  
  8.   int i, j, preferred_row, count=0;
  9.   float sum = 0, avg, arr[ROW][COLUMN];
  10.   char op;
  11.   scanf("%d %c", &preferred_row, &op);
  12.  
  13.   for (i = 0; i < ROW; i++)
  14.   {
  15.     for (j = 0; j < COLUMN; j++)
  16.     {
  17.       scanf("%f", &arr[i][j]);
  18.     }
  19.   }
  20.   for (i = preferred_row-1; i <= preferred_row-1; i++)
  21.   {
  22.     for (j = 0; j < COLUMN; j++)
  23.     {
  24.       printf("%.2f ", arr[i][j]);
  25.       sum += arr[i][j];
  26.       count+=1;
  27.     }
  28.   }
  29.   if (op == 'S')
  30.     printf("%.2f", sum);
  31.   else if (op=='M')
  32.   {
  33.     printf("%.2f", (float)sum/count);
  34.   }
  35.  
  36.   return 0;
  37. }
Add Comment
Please, Sign In to add comment