answersLogoWhite

0

..use do{} while{}..

for example..

#include
main(){
int choose;
double a,b,c;
printf("Enter 7 if you want to use the calculator. Otherwise,type any character.\n");
scanf("%d",&choose);
do{
if (choose==7){
printf("Press 1 for addition.\n");
printf("Press 2 for subtraction.\n");
printf("Press 3 for multiplication.\n");
printf("Press 4 for division.\n");
scanf("%d",&choose);
if (choose==1){
printf("Enter the addends\n");
scanf("%lf %lf", &a,&b);
c=a+b,
printf("The sum of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==2){
printf("Enter the minuend and subtrahend\n");
scanf("%lf %lf", &a,&b);
c=a-b,
printf("The difference of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==3){
printf("Enter the multipliers\n");
scanf("%lf %lf", &a,&b);
c=a*b,
printf("The product of %lf and %lf is %lf.\n",a,b,c);
}else if(choose==4){
printf("Enter the dividend and divisor\n");
scanf("%lf %lf", &a,&b);
c=a/b,
printf("The quotient of %lf and %lf is %lf.\n",a,b,c);
}else{
printf("You have entered an invalid digit.\n");}
printf("If you want to continue,press 7 and choose again from 1 to 4.\n");
printf("Do you want to exit? Enter any key.\n");
scanf("%d",&choose);
}
}while(choose==7);
}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake

Add your answer:

Earn +20 pts
Q: How do you return to a main function?
Write your answer...
Submit
Still have questions?
magnify glass
imp