belongs to collection: C Programs to print Series
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.
#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:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer