Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- const int ROW = 4;
- const int COLUMN = 4;
- int main()
- {
- int i, j, preferred_row, count=0;
- float sum = 0, avg, arr[ROW][COLUMN];
- char op;
- scanf("%d %c", &preferred_row, &op);
- for (i = 0; i < ROW; i++)
- {
- for (j = 0; j < COLUMN; j++)
- {
- scanf("%f", &arr[i][j]);
- }
- }
- for (i = preferred_row-1; i <= preferred_row-1; i++)
- {
- for (j = 0; j < COLUMN; j++)
- {
- printf("%.2f ", arr[i][j]);
- sum += arr[i][j];
- count+=1;
- }
- }
- if (op == 'S')
- printf("%.2f", sum);
- else if (op=='M')
- {
- printf("%.2f", (float)sum/count);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment