你第二个IF 包括在第一个IF里面了 当输入比5大的数时,显示正确,但是输入比5小或者就是5时,程序执行scanf语句完后,就直接跳到getch()语句,当然不对,我修改了下,仅供参考!
#include<stdio.h>
int main()
{
int n=5;
int number;
printf("Entre a number that between 1 and 10 you want write:\n");
scanf("%d",&number);
if(number>n)
printf("The number is greater than 5");
else if(number<n)
printf("The number is less than 5");
else printf("The number is same with 5");
getch();
}
#include<stdio.h>
int main()
{
int n=5;
int number;
printf("Entre a number that between 1 and 10 you want write:\n");
scanf("%d",&number);
if(number>n)
printf("The number is greater than 5");
else if(number<n)
printf("The number is less than 5");
else printf("The number is same with 5");
getch();
}