Wednesday 11 May 2016

c program to print the pattern

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j;
clrscr();
printf("Enter the value for n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i>0 && i<(n-1))
if(j==0 | j==(n-1))
printf("g");
else
printf(" ");
else
printf("g");
}
printf("\n");
}
getch();
}

No comments:

Post a Comment