Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

Develop a program that will display a rectangle of *

Example :     5
Columns:      7


      *******
      *******
      *******
      *******
      *******

Posted by uehara123 2019-01-24 03:38:10

#include<iostream>
using namespace std;

int main(){
int rows, cols;

cout<<"
 Enter number of rows : "; 
cin>>rows;
cout<<"
 Enter number of columns : ";
cin>>cols;

cout<<"
 Output is : 
";

for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++)
cout<<"*";
cout<<"
";
}
return 0;

}

C++ user image Admin posted 2019-01-24 14:42:36

#include <stdio.h>

int main()
{
    int i, j, rows, columns;

    printf("Enter number of rows: ");
    scanf("%d", &rows);
    printf("Enter number of columns: ");
    scanf("%d", &columns);

    for(i=1; i<=rows; i++)
    {
        for(j=1; j<=columns; j++)
        {
            printf("*");
        }
        printf("
");
    }

    return 0;
}

Output:
Enter number of rows: 5
Enter number of columns:7
 *******
 *******
 *******
 *******
 *******

C++ user image Sherin posted 2019-04-21 21:53:52

Please login to comment

Log In


Ask New Question