Write a program in C++ that 1.Initialize or read in the elements of the followin
ID: 3860820 • Letter: W
Question
Write a program in C++ that
1.Initialize or read in the elements of the following two-dimensional array. You may use an initializer statement, or stream I/O statement, to read the elements into an array
4 1 6 9
1 2 3 4
7 6 5 4
3 8 3 9
1 5 7 3
2.Print the elements of the two-dimensional array, in the format above, and nothing else.
3.Print the elements of the array and the sum of each row
4.Print row identification, elements of each row, and averages of each row
5.Print the sum and average of all the elements of the array as follows
The sum of all the elements is
The average of all the elements is
Explanation / Answer
Answer :- I have'nt include the header files in all i have given onlt the main program . you include the header files to run the program
Part 1:-
# include<iostream.h>
using namespace std;
int main()
{
int a[5][4], i,j;
for (i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
cin>> a[i][j];
}
}
Part 2:-
for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
cout << [i][j];
}
}
Part 3:-
for (i=0;i<5;i++)
int s=0;
{
for (j=0;j<4;j++)
{
cout<< a[i][j];
s+=a[i][j];
}
cout<< s;
}
Part 4:-
for(i=0;i<5;i++)
cout<<"row";
{
cout<< i+1; int s=0;
for(j=0;j<4;j++)
{
s+=a[i][j];
}
s/=4;
cout<<s;
}
int s=0;
part 5:-
for(i=o;i<5;i++)
{
for(j=0;j<4;j++)
{
s+=a[i][j];
}
}
cout<<"sum"<<s;
s/=20;
cout<<"avg"<<a;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.