Thursday, February 5, 2009

Exer3


#include
#include


int i,j,x,y,A,B,C,D,pattern;
void main()
{
clrscr();

printf("\n\t[A]Enter Pattern 1");
printf("\n\t[B]Enter Pattern 2");
printf("\n\t[C]Enter Pattern 3");
printf("\n\t[D]Enter Pattern 4");
printf("\n\tEnter Pattern:");
scanf("%s",&pattern);

switch(pattern)
case 'A':
for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x++) { gotoxy(x,y); printf("*"); }} switch(pattern) case 'B': for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x--) { gotoxy(x,y); printf("*"); } } switch(pattern) case 'C': for(i=4,y=8;i<=4;i--,y++) { for(j=i,x=35;j>=1;j--,x++)
{
gotoxy(x,y);
printf("*");
}
}
switch(pattern)
case 'D':
for(i=4,y=8;i>=1;i--,y++)
{
for(j=i,x=35;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*");
}}
getch();
}

No comments: