Answer to Question #277936 in C++ for allie

Question #277936

Using a two-dimensional array, design a program that asks the user to give the size of an array and ask the user to give a series of numbers. The program will determine and display which of the given numbers has the biggest in terms of numerical value.



1
Expert's answer
2021-12-10T00:38:32-0500
#include<iostream>
using namespace std;
int main(){
	cout<<"Enter the rows of the array:\n";
	int row;
	cin>>row;
		cout<<"Enter the columns of the array:\n";
	int col;
	cin>>col;
	cout<<"Enter the elements of the array:\n";
	int arr[row][col];
	for(int i=0; i<row; i++){
		for(int j=0; j<col; j++){
			cin>>arr[i][j];
		}
	}
	int max = arr[0][0];
	for(int i=0; i<row; i++){
		for(int j=0; j<col; j++){
			if(arr[i][j]>max){
				max = arr[i][j];
			}
		}
	}
	cout<<"Maximum element is: "<<max<<endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog