Advertisement

Making Double diamond with star

#include <stdio.h>
#include <conio.h>
#include <math.h>
 main ()
{
    int i,j,k,r,m;
    printf("put row number");
    scanf("%d",&r);
m=r;
   
    for(i=1;i<=r;++i) 
    {
                     for(j=m-i;j>=0;j--)
                     printf(" ");
                     for(k=1;k<=i;++k)      
                     printf("* ");
                      printf("\n");                            
     }
 
    for(i=1;i<=r;++i) 
    {
                     for(j=m-(i+1);j<r;j++)
                     printf(" ");
                     for(k=r;k>i;--k)      
                     printf("* ");
                      printf("\n");
                     
}      getch();
     return 0;
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge