C

C Program To Print Square Star Pattern

In this tutorial, we are going to see how to write a C program to print square star pattern. To print a square star pattern of N lines made of stars, We use for loop. Below is the logic for displaying a square pattern of N lines made of stars in C programming.
 

Input :
Number of Lines: 5

Output :
*****
*****
*****
*****
*****

 

 

C Program To Print Square Star Pattern
#include<stdio.h>
 
int main()
{
    int i, j, lines;

    printf("Enter the number of lines: ");
    scanf("%d",&lines);
    printf("\n");

    for(i=0; i < lines; i++)
    {
        for(j=0; j < lines; j++)
        {
           printf("*");
        }
        printf("\n");
    }
    return 0;
}

Output:

Enter the number of lines: 5

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

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *