判断奇偶
程序核心——判断语句
程序
#include<stdio.h>
int main()
{
int number;
printf("Enter number:");
scanf("%d",&number);
if(number%2==0)//两数相等
printf("The number is even.
");
else
printf("The number is odd.
");
return 0;
}
结果
Enter number:3
The number is odd.
--------------------------------
Process exited after 1.916 seconds with return value 0
请按任意键继续. . .
分析
重点:判断语句,注意判断条件是否存在遗漏