Consider a two-by-three integer array t: a). Write a statement that declares and creates t. b). Write a nested for statement that initializes each element of t to zero. c). Write a nested for statement that inputs the values for the elements of t from the user. d). Write a series of statements that determines and displays the smallest value in t. e). Write a series of statements that displays the contents of t in tabular format. List the column indices as headings across the top, and list the row indices at the left of each row.

Respuesta :

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

int main(){

   int t[2][3];

   for(int i = 0;i<2;i++){

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

           t[i][i] = 0;        }    }

   

   cout<<"Enter array elements: ";

   for(int i = 0;i<2;i++){

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

           cin>>t[i][j];        }    }

   

   int small = t[0][0];

   for(int i = 0;i<2;i++){

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

           if(small>t[i][j]){small = t[i][j];}        }    }

   

   cout<<"Smallest: "<<small<<endl<<endl;

   

   cout<<" \t0\t1\t2"<<endl;

   cout<<" \t_\t_\t_"<<endl;

   for(int i = 0;i<2;i++){

       cout<<i<<"|\t";

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

           cout<<t[i][j]<<"\t";

       }

       cout<<endl;    }

   return 0;

}

Explanation:

See attachment for complete source file where comments are used to explain each line

Ver imagen MrRoyal