Answer:
See explaination
Step-by-step explanation:
#include <iostream>
#include <iomanip>
using namespace std;
int main( )
{
//2D array with 4 rows and 3 columns and initializing it with zeros
int arr[4][3]={0};
int i,j;
//for taking input
int x;
//for counting number of numeric inputs
int cnt=0;
//for storing maximum value
int maxi=0;
//for storing sum of all numeric values
float sum=0;
cout<<"Enter up to 12 intergers,seperated by spaces, terminated with a non-numeric:\\";
//taking 12 inputs
for(i=0;i<4;i++){
for(j=0;j<3;j++){
//taking input in x
cin>>x;
//if input is non-numeric then break
if(x==0){
break;
}
//counting the number numeric inputs
cnt++;
//calculating sum of all numeric values
sum+=x;
//finding maximum among all numeric values
maxi=max(maxi,x);
//storing the input in 2D array
arr[i][j]=x;
}
//if input is non-numeric then break
if(x==0){
break;
}
}
//calculating average of all numeric values
float avg=sum/cnt;
//displaying average and maximum
cout<<"Average = "<<avg<<"\\";
cout<<"Maximum = "<<maxi<<"\\";
//displaying 4x3 matrix
cout<<"4x3 matrix:\\";
for(i=0;i<4;i++){
for(j=0;j<3;j++){
cout<<arr[i][j]<<setw(3);
}
cout<<"\\";
}
//displaying transpose of matrix
cout<<"3x4 matrix:\\";
for(i=0;i<3;i++){
for(j=0;j<4;j++){
cout<<arr[j][i]<<setw(3);
}
cout<<"\\";
}
return 0;
}