Do a C++ program using nested loops to create the following report:Prompt the user for number of rows and columns and create a table with the number of rows and columns that was given by the end user and repeat this process by asking the user if the user wants to continue. If the user says Y or y you’ll clear the screen and start all over again and if the user enters N or n you’ll stop the loop and output the “Thank you” note.
#include <iostream>
using namespace std;
int main()
{
int rows, columns;
char answer;
do{
cout << "Enter number of rows: ";
cin >> rows;
cout << "Enter number of columns: ";
cin >> columns;
cout << endl << "\nYour table" << endl;
for(int i = 1; i <= rows; i++)
{
for(int j = 1; j <= columns; j++)
cout << "-" << " ";
cout << endl;
}
cout << endl << endl << "Do you want to continue[Y/N]? ";
cin >> answer;
}while(answer=='Y');
cout << "Thank you";
return 0;
}
Comments
Dear client, please use panel for submitting questions
How do you put the numbers in for the rows and columns?
Leave a comment