What Is Wrong With This C Code?

vlaki007

Estimable
Sep 28, 2015
1
0
4,510
#include <stdio.h>
#include <stdlib.h>


int main()
{
int x;
int y;
int answer;
int operationType;

printf("Welcome to Vladimir's calculator \n");

printf("What do you want me to do? \n 1.add ; 2.subtrack ; 3.devide ; 4.multiply \n");
scanf(" %d \n", &operationType);

if(operationType == 1){
printf("You have chosen to add! \n Give me 1st number: ");
scanf(" %d \n", &x);
printf("give me the 2nd number: ");
scanf(" %d \n", &y);

answer = x + y;

printf(" %d \n", answer);
}
if(operationType == 2){
printf("You have chosen to subtrackt! \n Give me 1st number: ");
scanf(" %d \n", &x);
printf("give me the 2nd number: ");
scanf(" %d", &y);

answer = x - y;

printf(" %d + %d = %d", x, y, answer);
}
if(operationType == 3){
printf("You have chosen to devide! \n Give me 1st number: ");
scanf(" %d \n", &x);
printf("give me the 2nd number: ");
scanf(" %d", &y);

answer = x / y;

printf(" %d", answer);
}
if(operationType == 4){
printf("You have chosen to multiply! \n Give me 1st number: ");
scanf(" %d \n", &x);
printf("give me the 2nd number: ");
scanf(" %d", &y);

answer = x + y;

printf(" %d", answer);
}
printf("The end");

return 0;
}

// no errors accure, but it does not give the right answer