数字0是奇数还是偶数
Here you will get C program to check given number is even or odd.
在这里,您将获得C程序来检查给定的数字是偶数还是奇数。
We will use following simple logic in this program.
我们将在该程序中使用以下简单逻辑。
If a number is divisible by 2 then it is even.
如果数字可以被2整除,那么它是偶数。
If a number is not divisible by 2 then it is odd.
如果一个数字不能被2整除,那么它是奇数。
#include<stdio.h>int main(){int n;printf("Enter any number:");scanf("%d",&n);if(n%2==0)printf("The number is even");elseprintf("The number is odd");return 0;}
Output
输出量
Enter any number:17The number is odd
输入任意数字:17该数字为奇数
翻译自: //02/c-program-to-check-whether-given-number-2.html
数字0是奇数还是偶数