我有两个问题,关于为什么我不能直接打印%
以及为什么此代码不起作用,但是当我将第二个块放在第一个块上方时它可以工作。这是怎么回事?
//Calculator
#include<stdio.h>
#include<conio.h>
void main(){
int a,b;
char c;
//First block
printf("Enter the two numbers\n");
scanf("%d%d",&a,&b);
//Second block
printf("\nPress + for ADD\nPress - for SUB\nPress * for MUL\nPress / for DIV\n");
printf("Press %c for MOD\n",'%');
scanf("%c",&c);
switch(c){
case '+': printf("%d + %d = %d",a,b,a+b);
break;
case '-': printf("%d - %d = %d",a,b,a-b);
break;
case '*': printf("%d * %d = %d",a,b,a*b);
break;
case '/': printf("%d / %d = %d",a,b,a/b);
break;
case '%': printf("%d %c %d = %d",a,'%',b,a%b);
break;
default: printf("Invalid Choice!");
}
getch();
}