Saturday, September 17, 2011

Pyramid of Stars

Here is a code to develop a program that will print triangle of stars on the screen.






Code :

#include
#include
void main()
{
int i,j,k,n;
clrscr();
printf("\n\tEnter a number(2 to 25):");
scanf("%d",&n);
for(i=0;i
{
printf("\n");
for(j=0;j
printf(" ");

for(k=0;k<2*i+1;k++)
{
cprintf("*");textcolor(k);
}
}
getch();
}

No comments:

Post a Comment