Char issue

#include <stdio.h>

int main()
{
int a ,b,result;
char ch;
printf(“enter operands\n”);
scanf("%d%d",&a,&b);
printf(“enter operation : “);
scanf(”%c”,&ch);
if(ch==’+’)
{
result=(a+b);
printf("%d",result);
}
else if(ch==’-’)
{
result=(a-b);
printf("%d",result);
}
return 0;
}

this code is not scanning ch tell whats the error and whats the solution

I’m not a C-guy, but try adding a space before the %c: Difference between scanf("%c", &c) and scanf(" %c", &c) - Stack Overflow

2 Likes

bro it actually worked