Advertisement
Programmin-in-Python

C Program for printing a SQUARE PATTERN of a character

Jan 16th, 2022
1,089
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int n; char c;
  5.     printf("Enter the Character : "); scanf("%c",&c);
  6.     printf("\nEnter the side of square : "); scanf("%d",&n);
  7.  
  8.     for(int i=0; i<n; i++){
  9.         for(int j=0; j<n; j++){
  10.             if(i==0||i==n-1){printf("%c ",c);}
  11.             else if(j==0||j==n-1){printf("%c ",c);}
  12.             else{printf("  ");}
  13.         }
  14.         printf("\n");
  15.     }
  16.     return 0;
  17. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement