Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that takes input from a user for number of rows and number of co

ID: 3590234 • Letter: W

Question

Write a program that takes input from a user for number of rows and number of columns and prints out a block of characters that is based on these 2 parameters. The program should keep asking the user for input, and printing out the result, until the user enters zero for each of the input parameters. A session should look exactly like the following example (including whitespace and formatting - although note that there is no whitespace at the end of each of these lines), with all manners of different numbers for inputs and the output $./block Enter number of rows and columns 10 10 X. X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X.X. X. X.X.X.X.X.X.X.X.X X.X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X.X X.X.X.X.X.X.X.X.X.X. X. X.X.X.X.X.X.X.X.X. X. X.X.X.X.X.X.X.X.X. Enter number of rows and columns: X. X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X X.X.X.X.X.X.X.X.X X. X.X.X.X.X.X.X.X X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X. X.X.X.X.X.X.X.X.X

Explanation / Answer

#include<iostream>
using namespace std;
int main(){
int rows,columns,i,j;
//loop untill rows and columns both not zero
do{
cout << "Enter number of rows and columns:"<<endl;
//get rows and columns
cin >> rows >> columns;
//loop through each row
for(int i=0;i<rows;i++){
//loop through each column
for(int j=0;j<columns;j++){
//print output
cout << "X.";
}
cout << endl;
}
}while(rows!=0 && columns!=0);
return 0;
}
/*
sample output
Enter number of rows and columns:
10 10
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.X.
Enter number of rows and columns:
9 9
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
X.X.X.X.X.X.X.X.X.
Enter number of rows and columns:
4 7
X.X.X.X.X.X.X.
X.X.X.X.X.X.X.
X.X.X.X.X.X.X.
X.X.X.X.X.X.X.
Enter number of rows and columns:
9 3
X.X.X.
X.X.X.
X.X.X.
X.X.X.
X.X.X.
X.X.X.
X.X.X.
X.X.X.
X.X.X.
Enter number of rows and columns:
0 0
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote