I am a beginner and attempted to make an calculator which uses i else to add or subtract. Whenever i choose add it still subtracts.Here is the code:

Code:

#include <stdio.h>
main()
{
int x, y, z, sum, sub; /* make variables for storing numbers to be added or subtracted and the variables to store the sum and difference */
char type; /* variable to determine addition or subtraction */
printf("This calculator only knows how to add and subtract, so enter you want to add or subtract by A for add and anything else for subtract.\n ");
scanf(" %c", &type);
if (type == "A") /* if the user's input is A then there will be addition */
{
printf("Type the first number.\n "); /* inputs first number */
scanf(" %d", &x);
printf("Type the second one.\n ");
scanf(" %d", &y);
printf("Type the last one.\n ");
scanf(" %d", &z);
sum = x + y + z; /* determines the value of the sum*/
printf("The sum is: %d", sum); /* prints the sum*/
}
else /*otherwise there will be subtraction*/
{
printf("Type the first number.\n ");
scanf(" %d", &x);
printf("Type the second one.\n ");
scanf(" %d", &y);
printf("Type the last one.\n ");
scanf(" %d", &z);
sub = x - y - z;
printf("The difference is: %d", sub);
}
return 0;
}

Even if I type A the calculator would subtract the numbers