Program to print Solid rectangle star pattern

Program to print Solid rectangle star pattern

21 April 2023

21 April 2023

Write a program to print Solid rectangle star pattern



If you are from 2023 batch student, Join our Telegram group for placement preparation and coming placement drive updates : https://t.me/talentbattle2023

Description

Get the number of rows as the input and print the solid rectangle star pattern

Input:

 N= 4     

Output:

*  *  *  * 

*  *  *  *

*  *  *  *

*  *  *  *

 

C Program

#include <stdio.h>

 int main ()

 {

  int N, i, j;

  printf("Enter the number of rows: ");

  scanf("%d", &N);

    for( i=1; i<=N; i++)

    {

                for(j=1; j<=N; j++)

                {   

                      printf("*  ");    

                }

                printf("\n");

     }

return 0;

 

 }

 

C++ Program

#include <iostream>

using namespace std;

int main ()

 {

  int N, i, j;

  cout<<"Enter the number of rows: ";

  cin>>N;

    for( i=1; i<=N; i++)

    {

                for(j=1; j<=N; j++)

                {   

                      cout<<"*  ";    

                }

                cout<<"\n";

     }

return 0;

 }

 

Java Program

import java.util.Scanner;

public class Main

{

                public static void main(String[] args) {

                                Scanner sc = new Scanner(System.in);

                                System.out.println("Enter the number of rows: ");

                                int n= sc.nextInt();

                                for(int i=1; i<=n; i++)

    {

                for(int j=1; j<=n; j++)

                {   

                      System.out.print("*  ");    

                }

                System.out.println();

     }

    

                }

}

 

Python Program

n=int(input("Enter the number of rows: "))

for i in range(1,n+1):

    for j in range(1,n+1):

        print("* ",end="")

    print()


If you are from 2023 batch student, Join our Telegram group for placement preparation and coming placement drive updates : https://t.me/talentbattle2023


Related Articles

Ask Us Anything !