Can someone help me make a c program Follow the instructions


Can someone help me make a c++ program
Follow the instructions for starting C+ + and viewing the Introductory22.cpp file, which is contained in either the Cpp8\\Chap12\\Introductory22 Project folder or the Cpp8\\Chap12 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) The program should display the contents of the two-dimensional array, column by column and also row by row. Complete the program using a while statement in the outer loops and a for statement in the nested loops. Save and then run the program.

Solution

#include<iostream>
#define ROW 100
#define COL 100
using namespace std;

// Prototype of the functions
void acceptMatrixData(int mat[][COL], int, int);
void displayMatrixData(int mat[][COL], int , int);

// main function definition
int main()
{
// Declares a matrix with ROW and COL size
int matrix[ROW][COL];
// To store the row and column size of the matrix
int row, col;
// Accepts row and column size
cout<<\"\ Enter the row size: \";
cin>>row;
cout<<\"\ Enter the column size: \";
cin>>col;
// Calls the function to accept data for matrix
acceptMatrixData(matrix, row, col);
// Calls the function to display data for matrix
displayMatrixData(matrix, row, col);
}// End of main function

// Function to accept matrix data
void acceptMatrixData(int mat[][COL], int row, int col)
{
int r = 0, c;
cout<<\"\ Enter the data for \"<<row<<\" x \"<<col<<\" matrix: \";
// Outer loop using while for each row
while(r < row)
{
//Inner loop using for loop for each column
for(c = 0; c < col; c++)
{
cout<<\"\ Enter the data for [\"<<(r + 1)<<\", \"<<(c + 1)<<\"] : \";
cin>>mat[r][c];
}// End of for loop
// Increase the row counter by one
r++;
}// End of while loop
}// End of function

// Function to display the matrix
void displayMatrixData(int mat[][COL], int row, int col)
{
cout<<\"\ Contents of the Matrix: \ \";
int r = 0, c;
// Outer loop using while for row
while(r < row)
{
// Inner loop using for loop for column
for(c = 0; c < col; c++)
{
cout<<\" \"<<mat[r][c];
}// End of for loop
cout<<endl;
// Increase the row counter by one
r++;
}// End of while loop
}// End of function

Sample Run:


Enter the column size: 3

Enter the data for 3 x 3 matrix:
Enter the data for [1, 1] : 10

Enter the data for [1, 2] : 20

Enter the data for [1, 3] : 30

Enter the data for [2, 1] : 40

Enter the data for [2, 2] : 50

Enter the data for [2, 3] : 60

Enter the data for [3, 1] : 70

Enter the data for [3, 2] : 80

Enter the data for [3, 3] : 90

Contents of the Matrix:
10 20 30
40 50 60
70 80 90

 Can someone help me make a c++ program Follow the instructions for starting C+ + and viewing the Introductory22.cpp file, which is contained in either the Cpp8
 Can someone help me make a c++ program Follow the instructions for starting C+ + and viewing the Introductory22.cpp file, which is contained in either the Cpp8

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site