program3_03.c
来自「C语言入门经典一书的所有代码。书上面的所有代码均在此。希望大家喜欢」· C语言 代码 · 共 29 行
C
29 行
/* Program 3.3 Using nested ifs to analyze numbers */
#include <stdio.h>
#include <limits.h> /* For LONG_MAX */
int main(void)
{
long test = 0L; /* Stores the integer to be checked */
printf("Enter an integer less than %ld:", LONG_MAX);
scanf(" %ld", &test);
/* Test for odd or even by checking the remainder after dividing by 2 */
if( test % 2L == 0L)
{
printf("The number %ld is even", test);
/* Now check whether half the number is also even */
if ( (test/2L) % 2L == 0L)
{
printf("\nHalf of %ld is also even", test);
printf("\nThat's interesting isn't it?\n");
}
}
else
printf("The number %ld is odd\n", test);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?