Description

Hello Guys... Here will be write a program , the program is how to print the star square pattern and provide the code.

So let's get started code....

#include<stdio.h>

int main(){
    int n,i, j;
    printf("Enter the pattern Size : ");
    scanf("%d", &n);
    for(i=1; i<=n; i++){
        for(j=1; j<=n; j++){
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

 

Output :
Enter the pattern Size : 5
*****
*****
*****
*****
*****

Step 1: Initilized some variable n,i, j.

  • the Variable of n stored the value of the size of pattern.
  • the Variable of i is used to iterate the loop
  • the Variable of j is used to iterate the second loop

Here we used to solve this program, used the nested for loop.

Step 2: Print the message for user for take the input by user.

Step 3: Take the input with from user with the help of scanf library funciton.

Step 4: Start the for loop from 1 to given number by user 'n'.

  • When this loop condition is true the go through the nested for loop.

Step 5: After print the full line of start then print the new line by '\n'.

Step 6: Exit.

Thanks....

Comments

Login is mandatory to comment Please login

Recommended Posts

All Pattern Program | C programming Language

All pattern programs code is availabel in this post. So Let's code now..