# Why my code is not working plz help !!!!

// ***** CALCULATOR *****

#include <stdio.h>

int main()
{
int num1,num2;
char ch,a,b,c,d;
printf("Enter the 1st number : ");
scanf("%d",&num1);
printf("Enter the 2nd number : ");
scanf("%d",&num2);

printf("2. Enter 'b' for minus\n");
printf("3. Enter 'c' for multipoltion\n");
printf("4. Enter 'd' for divition\n");
scanf("%c",&ch);

a = '+';
b = '-';
c = '*';
d = '/';

if(ch == 'a') {
printf("Ans is %d\n",num1 + num2);
}

else if(ch == 'b') {
printf("Ans is %d\n",num1 - num2);
}

else if(ch == 'e') {
printf("Ans is %d\n",num1 * num2);
}

else if(ch == 'd') {
printf("Ans is %d\n",num1 / num2);
}

else {
printf("Incorrect input\n");
}

return 0;
}

answered Jul 1, 2021 by (270 points)
Dont put printf just print
answered Jul 7, 2021 by (140 points)
CORRECT CODE:-
#include <stdio.h>
int main(){
int num1,num2;
char ch,a,b,c,d;

printf("2. Enter 'b' for minus\n");
printf("3. Enter 'c' for multipoltion\n");
printf("4. Enter 'd' for divition\n");
scanf("%c",&ch);

printf("Enter the 1st number : ");
scanf("%d",&num1);
printf("Enter the 2nd number : ");
scanf("%d",&num2);

a = '+';
b = '-';
c = '*';
d = '/';

if(ch == 'a') {
printf("Ans is %d\n",num1 + num2);
}else if(ch == 'b') {
printf("Ans is %d\n",num1 - num2);
}else if(ch == 'c') {
printf("Ans is %d\n",num1 * num2);
}else if(ch == 'd') {
printf("Ans is %d\n",num1 / num2);
}else {
printf("Incorrect input\n");
}
return 0;
}