Monday, February 16, 2009

EXER 5




#include
#include
void main(){clrscr();int row,a,b,c,d,choice;gotoxy(3,2);textcolor(YELLOW);cprintf("Enter the number of rows you want to display: ");scanf("%d",&row);gotoxy(5,4);textcolor(YELLOW);cprintf("Select pattern you want to print:");gotoxy(7,6);textcolor(GREEN);cprintf("[A] Pattern 1");gotoxy(7,7);textcolor(GREEN);cprintf("[B] Pattern 2");gotoxy(7,8);textcolor(GREEN);cprintf("[C] Pattern 3");gotoxy(7,9);textcolor(GREEN);cprintf("[D] Pattern 4");gotoxy(7,11);textcolor(YELLOW);cprintf("Please make your choice: ");scanf("%s",&choice);switch(choice){case 'A':case 'a':for(a=0,d=12;a<=row;a++,d++){for(b=1,c=37;b<=a;b++,c++){gotoxy(c,d);textcolor(CYAN);cprintf("*");} }break; case 'B':case 'b': for(a=0,d=12;a<=row;a++,d++){for(b=1,c=37;b<=a;b++,c--){gotoxy(c,d);textcolor(CYAN);cprintf("*");} }break; case 'C':case 'c':for(a=row,d=13;a<=row;a--,d++){for(b=a,c=38;b>=1;b--,c++){gotoxy(c,d);textcolor(CYAN);cprintf("*");}}break;case 'D':case 'd':for(a=row,d=13;a>=1;a--,d++){for(b=a,c=38;b>=1;b--,c--){gotoxy(c,d);textcolor(CYAN);cprintf("*");}}break;default:gotoxy(5,4);textcolor(MAGENTA);cprintf("Sorry input not available!!");}getch();}

No comments:

Post a Comment