***C Programming***
Given a 2D array. Write a function that will take the 2D array as argument and then print the maximum number in each row of that 2D array.
#include <stdio.h>
void printMaxAtEachRow(int arr[][3],int r,int c){
int i,j,max;
//iterating the loop
for(int i=0;i<3;i++){
//assuming 1st element as max
max=arr[i][0];
for(int j=0;j<3;j++){
//checking any other element is greater than this
if (max<arr[i][j])
max=arr[i][j];
}
printf("Max at row : %d : %d\n",i+1,max);
}
}
int main() {
int arr[][3]={{10,8,4},{3,2,7},{19,1,13}};
printMaxAtEachRow(arr,3,3);
}
Get Answers For Free
Most questions answered within 1 hours.