在做编程题有个地方有点问题:
#include<stdio.h>
int main(void)
{
int num1,num2,he,cha,ji,shang,yu;
printf("Enter num1:");
scanf("%d",&num1);
printf("Enter num2:");
scanf("%d",&num2);
he=num1+num2;
printf("%d+%d=%d\n",num1,num2,he);
cha=num1-num2;
printf("%d-%d=%d\n",num1,num2,cha);
ji=num1*num2;
printf("%d*%d=%d\n",num1,num2,ji);
shang=num1/num2;
printf("%d/%d=%d\n",num1,num2,shang);
yu=num1%num2;
printf("%d%%d=%d\n",num1,num2,yu);
return 0;
}
这一段代码,原本最后应该是5%3=2,为什么显示为5%d=3?????
#include<stdio.h>
int main(void)
{
int num1,num2,he,cha,ji,shang,yu;
printf("Enter num1:");
scanf("%d",&num1);
printf("Enter num2:");
scanf("%d",&num2);
he=num1+num2;
printf("%d+%d=%d\n",num1,num2,he);
cha=num1-num2;
printf("%d-%d=%d\n",num1,num2,cha);
ji=num1*num2;
printf("%d*%d=%d\n",num1,num2,ji);
shang=num1/num2;
printf("%d/%d=%d\n",num1,num2,shang);
yu=num1%num2;
printf("%d%%d=%d\n",num1,num2,yu);
return 0;
}
这一段代码,原本最后应该是5%3=2,为什么显示为5%d=3?????