Sunday, February 15, 2009

Exercise no. 5

Exercise # 5:

#include
#include
#include

void main(){
clrscr();
int h,i,j,x,y,choice,X;
gotoxy(26,3);textcolor(LIGHTCYAN+BLINK);cprintf("E X E R C I S E 5 / P A T T E R N");
gotoxy(25,4);textcolor(LIGHTRED);cprintf("\nEnter your favorite number:");
gotoxy(52,5);textcolor(WHITE);scanf("%d",&h);
gotoxy(25,6);textcolor(CYAN);cprintf("\nSelect pattern you like to appear!");
gotoxy(25,8);textcolor(BLUE);cprintf("\n\t[A] for Pattern 1");
gotoxy(25,9);textcolor(DARKGRAY);cprintf("\n\t[B] for Pattern 2");
gotoxy(25,10);textcolor(LIGHTGREEN);cprintf("\n\t[C] for Pattern 3");
gotoxy(25,11);textcolor(YELLOW);cprintf("\n\t[D] for Pattern 4");
gotoxy(25,13);textcolor(RED);cprintf("\nEnter your choice Pattern here:");
gotoxy(56,14);textcolor(WHITE);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(MAGENTA);cprintf("\n\nEnd of the program,Thankyou very much!!!! hahahahahah....");
getch();
}
OUTPUT:



No comments:

Post a Comment