1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GuDViN [60]
3 years ago
9

Write and debug this program in Visual C++, and upload for grading. Declare a 2D array, 4 rows by 3 columns, initialized to all

zeros. The program should prompt for and read a list of integers into the 2-dimensional array It should stop reading in new values when the user types a non-numeric or at 12 numbers, whichever comes first.
Then the program should print out:
• the average of the values entered
• the maximum value entered
• the array as a 4x3 matrix with spacing of 3 spaces per column (Hint: setw(3))
• the array transposed, as a 3x4 matrix (just print it in transposed order, do not create an actual 3x4 array. To print it transposed, just copy the nested loop that printed it as 4x3, and make the outer loop the columns and inner loop the rows)
Example program run the program prints everything below except the user input, whch is 1 2 3 4 5 6 74
Enter up to 12 integers, separated by spaces, terminated with a non-numeric: 1 2 3 4 5 6.79
Average - 4
Maximum
4x3 matrix
1 2 3
4 5 6
7 0 0
0 0 0
3x4 matrix
1 4 7 0
2 5 0 0
3 6 0 0
Computers and Technology
1 answer:
Ahat [919]3 years ago
3 0

Answer:

See explaination

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:\n";

//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<<"\n";

cout<<"Maximum = "<<maxi<<"\n";

//displaying 4x3 matrix

cout<<"4x3 matrix:\n";

for(i=0;i<4;i++){

for(j=0;j<3;j++){

cout<<arr[i][j]<<setw(3);

}

cout<<"\n";

}

//displaying transpose of matrix

cout<<"3x4 matrix:\n";

for(i=0;i<3;i++){

for(j=0;j<4;j++){

cout<<arr[j][i]<<setw(3);

}

cout<<"\n";

}

return 0;

}

You might be interested in
Program Convert Measurements:
worty [1.4K]

on the truth is that the walls

6 0
3 years ago
What is the role of the computer in banking system?
Daniel [21]

Answer: In banks, computers are used for keeping account information of customer accounts. Banks use technology to carry out payments effectively and successfully. Computers help bankers keep a record of and verify financial records much quicker. Hope this is helpful.

3 0
2 years ago
What are the three main desktop operating systems used today
Norma-Jean [14]

Answer:The three most common operating systems for personal computers are Microsoft Windows, macOS, and Linux.

Explanation:

3 0
3 years ago
2. Sebastian, an exchange student from Denmark, likes going out with his new friends but quickly becomes overwhelmed by their lo
nadya68 [22]

Answer:

Culture shock

Explanation:

Culture shock is an experience about a persona in another foreign country, this happens when someone moves to another country and unknown life, culture, and this new region, Common problems include: information overload, language barrier, generation gap, technology gap.

For example, if a Japanese moves to Africa, would be a huge change in culture, technology, language, even physical.

4 0
3 years ago
Is (x.y)' and x'.y' the same? Boolean Algebra
xeze [42]
No its not the same
7 0
4 years ago
Read 2 more answers
Other questions:
  • In 1–2 sentences describe how you would insert a row in a spreadsheet.
    11·1 answer
  • What is a googleplex?
    7·1 answer
  • Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer va
    7·1 answer
  • In cell K8, create a formula using the SUM function that calculates the total of the range D17:D20 and subtracts it from the val
    6·1 answer
  • Which is the least technically experienced technical support group?
    7·1 answer
  • Serting a header at the top of a page will make it appear on_____. ?
    13·1 answer
  • What is information cycle
    15·2 answers
  • 2.9.8 stop light codehs
    10·1 answer
  • What is a program answer these question<br>of grade-6​
    12·1 answer
  • explain how principles of computational thinking skills are applied in finding solutions that can be interpreted into software a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!