hello.c: In function 'main': hello.c:11:15: warning: unknown conversion type character 'y' in format [-Wformat=] printf("x%y=%d\n", x%y ); ^ x+y=7 x-y=13 x*y=-30 x/y=-3
printf("x%%y=%d\n", x%y );
y前面需要加一个% ,因为%y被当作特殊字符了(参考%d)
#include <stdio.h>
int main()
{
int x,y;
x = 10;
y = -3;
printf("x+y=%d\n", x+y );
printf("x-y=%d\n", x-y );
printf("x*y=%d\n", x*y );
printf("x/y=%d\n", x/y );
printf("x%%y=%d\n", x%y );
return 0;
}