In: Computer Science
wite a program in C to print a right and left pointing arrow pattern using '#' symbol. Do so within 10 lines i.e upper half of the occupies 5 lines and lower half occupies other 5 lones.
User will enter 'R' or'r' for printing right pointing arrow. 'l' or 'L' for left pointing arrow.'k'' for invalid option.
You must use if-else and while loop for do this.
Please find the code below::
#include<stdio.h>
#include<string.h>
int main(){
char choice;
while(1){
printf("Enter your choice (L l R r
k K) : ");
scanf("%c",&choice);
while(choice=='\n')
scanf("%c",&choice);
if(choice=='l'
||choice=='L'){
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("#############################\n");
printf("#############################\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
}else
if(choice=='R'||choice=='r'){
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("#############################\n");
printf("#############################\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
printf("
#\n");
}else if(choice =='k' || choice
=='K'){
break;
}else{
printf("Please
enter valid choice....\n");
}
}
return 0;
}
output: