#include#include
#include
void main()
{
clrscr();
int h,i,j,x,y,choice,X;
gotoxy(26,3);cprintf("P A T T E R N S");
gotoxy(25,4);textcolor(LIGHTRED);cprintf("\nEnter number:");
gotoxy(41,5);textcolor(RED);scanf("%d",&h);
gotoxy(25,6);textcolor(YELLOW);cprintf("\nChoose the desired pattern:");
gotoxy(25,8);cprintf("\n\t[A] for Pattern 1");
gotoxy(25,9);cprintf("\n\t[B] for Pattern 2");
gotoxy(25,10);cprintf("\n\t[C] for Pattern 3");
gotoxy(25,11);cprintf("\n\t[D] for Pattern 4");
gotoxy(25,13);textcolor(YELLOW);cprintf("\nEnter your choice from above:");
gotoxy(56,14);scanf("%s",&choice);
switch(choice)
{
case 'A':
for(i=1,y=15;i<=h;i++,y++)
{
for(j=1,x=40;j<=i;j++,x++)
{
gotoxy(x,y); printf("*"); } }
break;
}
switch(choice)
{ case 'B':
for(i=1,y=15;i<=h;i++,y++)
{
for(j=1,x=40;j<=i;j++,x--)
{
gotoxy(x,y); printf("*");
}
}
break;
}
switch(choice)
{
case 'C':
for(i=h,y=15;i<=h;i--,y++)
{
for(j=i,x=40;j>=1;j--,x++)
{ gotoxy(x,y); printf("*");
}
} break;
}
switch
(choice)
{
case 'D':
for(i=h,y=15;i>=1;i--,y++)
{
for(j=i,x=40;j>=1;j--,x--)
{
gotoxy(x,y); printf("*");
}
}
break;
}
gotoxy(15,20);textcolor(LIGHTBLUE);cprintf("\n\nthe program ends here.... thanks!!\n"); gotoxy(20,21);textcolor(YELLOW);cprintf("DONE BY: Diana Estrada");
getch();
}

No comments:
Post a Comment