Give numbers of rows and column from user, print a rectangle pattern as shown in the below example.
Example :
Input : row = 5, column = 4
Output :
* * * *
* * * *
* * * *
* * * *
* * * *
//C Program to Print Rectangle Pattern #include<stdio.h> int main() { int row, column; printf("Enter Numbers of Rows : "); scanf("%d", &row); printf("Enter Numbers of Columns : "); scanf("%d", &column); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { printf("* "); } printf("\n"); } return 0; }
//CPP Program to Print Rectangle Pattern #include<iostream> using namespace std; int main() { int row, column; cout << "Enter Numbers of Rows : "; cin >> row; cout << "Enter Numbers of Columns : "; cin >> column; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { cout << "* "; } cout << endl; } return 0; }
//Java Program to Print Rectangle Pattern import java.util.Scanner; public class Rectangle_Pattern { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int row, column; System.out.print("Enter Numbers of Rows : "); row = sc.nextInt(); System.out.print("Enter Numbers of Columns : "); column = sc.nextInt(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { System.out.print("* "); } System.out.println(); } } }
#Python Program to Print Rectangle Pattern row = int(input("Enter Numbers of Rows : ")) column = int(input("Enter Numbers of Columns : ")) for i in range(0, row): for j in range(0, column): print("*", end=' ') print()
Comments
Post a Comment