Print Friendly and PDF
(What Does This Program Do?) What does the following program do? #include < iostream> using namespace std; int main() { int x; // declare x int y; // declare y // prompt user for input cout << "Enter two integers in the range 1-20: "; cin >> x >> y; // read values for x and y for ( int i = 1; i <= y; ++i ) // count from 1 to y { for ( int j = 1; j <= x; ++j ) // count from 1 to x cout << '@'; // output @ cout << endl; // begin new line } // end outer for } // end main
(What Does This Program Do?) What does the following program do?

123456789101112131415161718192021#include < iostream>
using namespace std;
 
int main()
{
 
  int x; // declare x
  int y; // declare y
 
  // prompt user for input
   cout << "Enter two integers in the range 1-20: ";
    cin >> x >> y; // read values for x and y
 
    for ( int i = 1; i <= y; ++i ) // count from 1 to y
    {
     for ( int j = 1; j <= x; ++j ) // count from 1 to x
      cout << '@'; // output @
 
       cout << endl; // begin new line
   } // end outer for
} // end main

Solution:

Create a rectangle. The first integer is column count, the second is row count.
For example:
Enter two integers in the range 1-20:

5
10
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
@@@@@
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: