Translate

Labels

Wednesday 15 January 2014

DIAMOND PATTERN STARS IN C

A C program to print Diamond pattern stars .

Diamond of Stars


main()
{
int rows,i,j,space;
clrscr();
printf("Enter the number of Rows:");
scanf("%d",&rows);
space=rows-1;
for(i=1;i<=rows;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
space--;
for(j=1;j<=2*i-1;j++)
{
printf("*");
}
printf("\n");
}
space=1;
for(j=1;j<=rows-1;j++)
{
for(i=1;i<=space;i++)
{
printf(" ");
}
space++;
for(i=1;i<=2*(rows-j)-1;i++)
{
printf("*");
}
printf("\n");
}
getch();
}
                                   

                                                        TRY THIS

                                        Pyramid of Stars>>>>>>>>>

No comments: