Saturday, January 30, 2010

CHAP 3[E]i Print a number triangle pattern

Write a program to produce the following output:











void main()
{
int storec=0,x=0,storex=1,counter,count;

for(counter=1;counter>storec;counter++)
{
storec=counter;
printf("\n");

for(x=storex,count=1;count<=storec;x++,count++)
{
if(x==2)
printf(" ");
if(x==4)
printf(" ");
if(x==1)
printf(" ");

if(x==3||x==5||x==8||x==6||x==9||x==10)
printf(" %d",x);
else
printf("%d",x);
storex=x+1;
}

if(storex==11)
storec=999;
}
}

8 comments: