5: 判断奇偶

5 判断奇偶

作者: Turbo 时间限制: 1S 章节: 分支结构

问题描述 :
从键盘输入一个整数,编程判断它的奇偶性。

输入说明 :
输入一个数字n

输出说明 :
输出n是奇数还是偶数。比如,输入数字5,则输出“5 is odd”;输入数字6,则输出“6 is even”

输入范例 :
5
输出范例 :
5 is odd
代码:

#include <stdio.h>
int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		if (n % 2 == 0)
		{
			printf("%d is even", n);
		}
		else
		{
			printf("%d is odd", n);
		}
		printf("
");
	}
	return 0;
}
Yesterday is history,tomorrow ismystery,but today is a gift!That why it is called Present!
原文地址:https://www.cnblogs.com/VictorierJwr/p/12242178.html