Pages

Friday, October 9, 2015

Pattern : C program to print Square pattern based on given value N.

This program will print Square pattern based on given value of N. 

#include<stdio.h>
int main()
{
 int i,j, n=5;
 //Logic to print square based on given value of N... 
 
 for(i=0; i<n; i++)
 {
  for(j=0; j<n; j++)
   printf("* "); //one space in printf prints proper output
  printf("\n");
 }
 return 0;
}

Output of the program

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

No comments:

Post a Comment