Q:

C program to print any character in a square pattern

belongs to collection: C Programs to print Series

0

C program to print any character in a square pattern , You just need to ask character from the user and print it on the console.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
int main()
{
    int x = 0,y = 0;
    int ch = 0;
    unsigned int squareSide = 0;
    printf("Enter Side of a Square = ");
    scanf("%u",&squareSide);
    printf("\nEnter Character want to print in square pattern = ");
    fflush(stdin);
    ch = fgetc(stdin);
    //outer loop
    for(x = 0; x < squareSide; ++x)
    {
        //inner loop
        for(y = 0; y < squareSide; ++y)
        {
            fputc(ch,stdout);
        }
        printf("\n");
    }
    return 0;
}

Output:

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programs to print Series

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C program to print hollow square of stars... >>
<< C program to Print Square Star Pattern...