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.
#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;
}
Comments
Leave a comment