1. ## Multiple if statements

I cannot seem to get any of the if statements other than the first one to work. I have searched high and low for the cause and have come up with nothing.

Code:
```#include <stdio.h>
#include <conio.h>

int main(void)
{
int subt;
int mult;
int divi;
int num1;
int num2;
int sum;

printf("Add(1), Subtract(2), Multiply(3), Divide(4) \nEnter the corrisponding number for the action you want to take: ");

printf("Enter first digit: ");
scanf("%d", &num1);
printf("Enter second digit: ");
scanf("%d", &num2);

sum = num1 + num2;
}
if(subt == 2){
printf("Enter first digit:");
scanf("%d", &num1);
printf("Enter second digit:");
scanf("%d", &num2);

sum = num1 - num2;
}
if(mult == 3){
printf("Enter first digit:");
scanf("%d", &num1);
printf("Enter second digit:");
scanf("%d", &num2);

sum = num1 * num2;
}
if(divi == 4){
printf("Enter first digit:");
scanf("%d", &num1);
printf("Enter second digit:");
scanf("%d", &num2);

sum = num1 / num2;
}

getch();

}``` 2. You don't want to have 4 variables add,subt,mult and divi. Just create one called 'operation' or something similar. There are some other things you could do to make the code cleaner but that's your big problem. 3. Code:
`scanf("%d", &add, &subt, &mult, &divi);`
You're only telling the "scanf()" to read in one integer, but are giving it four arguments. Perhaps you mean to read the user input into a single variable, and use that single variable in all four of you "if()" statements.

Also, you're correctly declaring main as returning an integer, so don't forget the "return 0" statement at the end of "main()". 4. Thank you for the help guys that got it working. This is actually my first piece of code to write by myself without a tutorial. Still a lot to learn! 5. Indeed - and you seem to be going about your learning in the right way. Keep it up! 6. Also, keep in mind for the statement sum = num1 / num2;
if num1 = 9 and num2 = 10 the answer is 0. Popular pages Recent additions multiple if statements 