..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);
}
To return the exp. or const to the main fumction.
void display is the function name in which we want to perform some task or it might be to display something. But it has got its residence in the main() function that means that function's inputs are being supplied from the main(). void doesn't return anything so function call is made in main() which doesn't return anything back to it.
The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value. In C++ language, the main() function can be left without return value. By default, it will return zero. To learn more about data science please visit- Learnbay.co
It means end the function. Functions automatically end when execution reaches the end of the function, but you can return from a function at any point within the function with a return statement. If the function returns a value to its caller, you must provide a reachable return statement along with the value you wish to return.
A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.
If we consider any function that is not the main function that is declared as "bool" i.e it will return boolean values to the main function-0 & 1, meaning 'false' and 'true' respectively. If we have to tell the main function that the condition checked in the function is false or disagreed, then we return 0 to the main function and when we have to tell that the condition checked in the main function is true or agreed, then we return 1 to the main function.
To return the exp. or const to the main fumction.
To return the exp. or const to the main fumction.
In C/C++ programming and most other procedural languages, you use a return statement to return control to the calling function. In the case of the global main function, a returnstatement terminates the program, releasing all memory used by the program and returning control to the execution environment.Functions that return void do not return a value and therefore do not require a return statement, unless the function needs to return early (before falling off the end of the function). Functions that return values must use a returnstatement to return the appropriate value to the caller.In C++ (but not in C), the global main function does not require a return statement unless returning early. When omitted, the global main function implicitly returns the value 0 (to the execution environment) when execution falls off the end of the function. To return any other value, a return statement is required.
void display is the function name in which we want to perform some task or it might be to display something. But it has got its residence in the main() function that means that function's inputs are being supplied from the main(). void doesn't return anything so function call is made in main() which doesn't return anything back to it.
In C-programming: int main (void) { return 0; }
Example: int main (void) { puts ("Here is a function definition"); return 0; }
to pump blood throughout the body and keep you alive.
becoz the main program doesnot return any value to the os.
The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value. In C++ language, the main() function can be left without return value. By default, it will return zero. To learn more about data science please visit- Learnbay.co
It means end the function. Functions automatically end when execution reaches the end of the function, but you can return from a function at any point within the function with a return statement. If the function returns a value to its caller, you must provide a reachable return statement along with the value you wish to return.
A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.