Tuesday, February 11, 2014

Print Dimond using C Language


#include<stdio.h>
#include<math.h>
void main()
{
            int i=0,j=0,num=3;
            for(i=-num;i<=num;i++)
            {
                        for(j=-num;j<=num;j++)
                        if(abs(i)+abs(j)<=num)
                        {
                                    printf("*");
                        }
                        else
                        {
                                    printf(" ");
                        }
      printf("\n");
            }
}

Output of the program:
 


No comments:

Post a Comment