- You should really consider making functions for each mathematical operation and keep the
main()
simple.
As an example:
float addition(float num1, float num2){
return num1 + num2;
}
//or
void addition(float num1, float num2){
float result = num1 + num2;
printf("%0.2f", result);
}
In the second example, you create and destroy result
each function call.
Consider asking the user if they would like to return to the menu, in case they want to do multiple calculations.
You don't need multiple
printf
statements for the menu options. Simply continuing as such is needed:printf("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n\n");