答案 0 :(得分:0)
如果我累积了所有评论以及更多内容:
#include <stdio.h>
int main()
{
int num;
printf("enter a number less than 10 : ");
if (scanf("%d", &num) != 1)
puts("invalid input");
else if (num < 10)
puts("what an obidient savant you are!");
else
puts("wrong number");
return 0; // may be return an other value on error cases ?
}
示例:
pi@raspberrypi:/tmp $ gcc -pedantic -Wall c.c
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : 1
what an obidient savant you are!
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : z
invalid input
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : 20
wrong number
答案 1 :(得分:0)
printf()
完成的,但是您写了
print()
。 (所以您忘记了'f'。)正确的程序显示为:
int main(int argc, char *argv[]) {
int num;
printf("Enter a number less than 10:");
scanf("%d", &num);
if (num < 10) {
printf("What an obedient servant you are!\n");
}
}
顺便通知\n
:它会打印换行符。