Monday, 12 December 2011

C program to print diamond pattern



#include<stdio.h>

main()
{
int i,n,j,x;
printf("Enter a Number:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(x=0;x<n-i;x++)
{
printf("\t");
}
for(j=0;j<=i;j++)
{
printf("*\t\t");
}
printf("\n\n");
}
for(i=1;i<n;i++)
{
printf("\t");
for(x=1;x<=i;x++)
{
printf("\t");
}
for(j=n;j>i;j--)
{
printf("*\t\t");
}
printf("\n\n");
}
}




You Like It!? Then kindly share with your Friends.
Comments
3 Comments

3 comments:

shyama said...

nice work..very useful for the beginners....

Francy said...

;) thanks

RIZWAN KOLATH said...

Simple

Post a Comment