Exer5
#include
#include
void main(){
void main(){
int a, b, c;
int choice;
clrscr();
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: ");
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){
switch (choice){
case 'A':
printf("\n "); for(b=1; b<=a; b++) { for(c=1; c<=b; c++) printf("*"); printf("\n "); }
break;
case 'B':
case 'B':
printf("\n "); for(c=a; c>=1; c--) { for(b=1; b<=c; b++) printf("*"); printf("\n "); }
break;
case 'C':
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':
case 'D':
printf("\n "); for(int b=a-1; b>=0; b--) { for(int c=b; c }
getch();
getch();
}
No comments:
Post a Comment