Exer5
#include
#include
void main()
{
int a, b, c;
int choice;
clrscr();
printf("\n Enter a number: ");
scanf("%d", &a);
printf("\n\t\t[A] - Pattern 1\n\n");
printf("\t\t[B] - Pattern 2\n\n");
printf("\t\t[C] - Pattern 3\n\n");
printf("\t\t[D] - Pattern 4\n\n");
printf("Select your choice: ");
scanf("%s",&choice);
switch (choice)
{
case 'A':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;
case 'B':
printf("\n ");
for(c=a; c>=1; c--)
{
for(b=1; b<=c; b++)
printf("*");
printf("\n ");
}
break;
case 'C':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=(a-b); c++)
printf(" ");
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;
case 'D':
printf("\n ");
for(int b=a-1; b>=0; b--)
{
for(int c=b; c
printf(" ");
for(int d=0; d<=b; d++)
printf("*");
printf("\n ");
}
break;
default:
clrscr();
printf("\n\n\n\n\t\t\tYour choice is not available!\n\n\n\n\t\t\tTry again later...!!!");
}
getch();
}
#include
void main()
{
int a, b, c;
int choice;
clrscr();
printf("\n Enter a number: ");
scanf("%d", &a);
printf("\n\t\t[A] - Pattern 1\n\n");
printf("\t\t[B] - Pattern 2\n\n");
printf("\t\t[C] - Pattern 3\n\n");
printf("\t\t[D] - Pattern 4\n\n");
printf("Select your choice: ");
scanf("%s",&choice);
switch (choice)
{
case 'A':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;
case 'B':
printf("\n ");
for(c=a; c>=1; c--)
{
for(b=1; b<=c; b++)
printf("*");
printf("\n ");
}
break;
case 'C':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=(a-b); c++)
printf(" ");
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;
case 'D':
printf("\n ");
for(int b=a-1; b>=0; b--)
{
for(int c=b; c
printf(" ");
for(int d=0; d<=b; d++)
printf("*");
printf("\n ");
}
break;
default:
clrscr();
printf("\n\n\n\n\t\t\tYour choice is not available!\n\n\n\n\t\t\tTry again later...!!!");
}
getch();
}
No comments:
Post a Comment