Question

***C Programming*** Given a 2D array. Write a function that will take the 2D array as...

***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.

Homework Answers

Answer #1

#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);

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C Programming 1. Write a void function that takes in a 2D array of character and...
C Programming 1. Write a void function that takes in a 2D array of character and have it print out each array on a new numbered line on the console. 2. Illustrate the stack and the heap allocation. Specify what each variable value holds and where different references are pointing to. int main() { int myarray[3]; myfunction (myarray); } int myfunction(int* in) { int i; for (i = 0; i<3; i+= 1) { in[i] = i; } // illustrate the...
C programming Write a function that takes in a 2D char array (string array) and return...
C programming Write a function that takes in a 2D char array (string array) and return a 1D char array with all the elements connected together Hint: strlen(-char*-) //returns the length of a string strcat(-char* accum-, something to add) //works like string+= in java
Write a method called sumDiagonal() that takes a 2D array of int as an argument returns...
Write a method called sumDiagonal() that takes a 2D array of int as an argument returns the sum of the first element in the first row, the second element of the second row, the third element of the third row, etc. You may assume that the array is not jagged and has at least as many columns as rows.
Explain your code with comments. Solve in C++. Write a function named myFunc3() that takes a...
Explain your code with comments. Solve in C++. Write a function named myFunc3() that takes a 2D integer array NUMBERS[][50], and it size n and m. Then the function will print the sum of each row in one line.
C Programming: Write a function that takes in an array of integers and an integer containing...
C Programming: Write a function that takes in an array of integers and an integer containing the count of elements, then have it returns the sum of all the even values inside the array.
In C, write a function void (int number[ ]) sorts the given array of integers into...
In C, write a function void (int number[ ]) sorts the given array of integers into non-decreasing order, storing the result in the given array. The array of integers may have any number of elements, but the last element of the array must be zero
In C programming: Generalize the to_binary() function of Listing 9.8 (from your textbook) to a to_base_n(number,base)...
In C programming: Generalize the to_binary() function of Listing 9.8 (from your textbook) to a to_base_n(number,base) function that takes a second argument in the range 2–10. It then should convert (and print) the number that is its first argument to the number base given by the second argument. For example, tobasen(129,8) would display 201, the base-8 equivalent of 129. Test the function in a complete program.
Write a function to print a the MxN array to an output file. in c++ language
Write a function to print a the MxN array to an output file. in c++ language
DESCRIPTION: You will be given a 2D array, called matrix, of Strings. The array has an...
DESCRIPTION: You will be given a 2D array, called matrix, of Strings. The array has an unknown number of cells filled with data. Your goal is to iterate through the 2D array and keep a count of how many cells are full. You will be given the dimensions of the array. INPUT: All input has been handled for you: Two integers denoting the dimensions of the array. These are the integer variables rows and cols. A partially filled 2-D array....
Write a template function maxn() that takes as its arguments an array of items of type...
Write a template function maxn() that takes as its arguments an array of items of type T and an integer representing the number of elements in the array and that returns the largest item in the array. The number of elements should take the default value of 10. The program should include a specialization that takes an array of strings as an argument and returns the longest string. (If there is a tie, the function should return the first one...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT