Thursday, 6 October 2011

Diamond in C


/* A Diamond in C
     *
    * *
   * * *
  * * * *
 * * * * *               */


 #include<stdio.h>
 #include<conio.h>
 void main()
 {
 int s=5;x,y;
 clrscr();
 for(x=1;x<=5;x++)
 {
 for(s=5;s>=x;s--)
 printf(" ");
 for(y=1;y<=x;y++)
 {
 printf(" *");
 }
 printf("\n");
 }
 getch();
 }


Note: There is a space in second last printf("_*");

No comments:

Post a Comment