Monday, 6 January 2014

PROGRAM TO PRINT HOLLOW DAIMOND....!!!!!

#include<stdio.h>
int main()
{
    int x,y,z;
    int size=10;
    for(x=0;x<10;x++)
    {
       for(z=0;z<size;z++)
       printf(" ");
       size--;
       for(y=0;y<=2*x;y++)
       {
           if(x>0&&x<=9&&y>0&&y<2*x)
           printf(" ");
           else
           printf("*");
       }
       printf("\n");
    }
    size++;
    //for lower half of empty daimond;
      for(x=8;x>=0;x--)
    {
       size++;
       for(z=0;z<size;z++)
       printf(" ");
      
       for(y=0;y<=2*x;y++)
       {
           if(x<=8&&x>0&&y>0&&y<2*x)
           printf(" ");
           else
           printf("*");
       }
       printf("\n");
    }
   
    getch();
    return 0;
}

EXPECTED OUTPUT:

 

No comments:

Post a Comment