fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int rows, cols;
  7. // Getting dimensions of the rectangle.
  8. cout << "Enter the number of rows in rectangle - ";
  9. cin >> rows;
  10.  
  11. cout << "Enter the number of columns in rectangle - ";
  12. cin >> cols;
  13.  
  14.  
  15. cout << "Rectangle of dimensions " << rows << "*" << cols << endl;
  16.  
  17. // Main logic to print Rectangle.
  18. for( int i = 0; i < rows; i++ ) {
  19. for( int j = 0; j < cols; j++ ){
  20. cout << "* ";
  21. }
  22. cout<<endl;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 5292KB
stdin
5
6
5*6
stdout
Enter the number of rows in rectangle - Enter the number of columns in rectangle - Rectangle of dimensions 5*6
* * * * * * 
* * * * * * 
* * * * * * 
* * * * * * 
* * * * * *