In: Computer Science
C language
write a code: Do you want another choice, if yes press (Y or y) then continue , if no press (N or n) then break.
Hi, i am taking one example for better understanding of the above question. If you want any modification please ask me in the comment section.
for the given question the code will be
CODE: C Programming Language
#include <stdio.h>
int main(){
while(1){
printf("Do you want
another choice: ");
char choice;
scanf("%s",
&choice);
if(choice == 'Y' ||
choice == 'y'){
continue;
}
else if(choice == 'N' ||
choice == 'n'){
break;
}
}
return 0;
}
SCREENSHOT OF THE CODE:

OUTPUT:

====================================================================
The example i am taking sqaure of number.
CODE: C Programming Language
#include <stdio.h>
int main(){
while(1){
int num;
printf("Enter a number:
");
scanf("%d",
&num);
int square = num *
num;
printf("Square is:
%d\n", square);
printf("Do you want
another choice: ");
char choice;
scanf("%s",
&choice);
if(choice == 'Y' ||
choice == 'y'){
continue;
}
else if(choice == 'N' ||
choice == 'n'){
break;
}
}
return 0;
}
SCREENSHOT OF THE CODE:

OUTPUT:
