作业帮 > 综合 > 作业

c语言求拆分4位数,使各位数相加,判断是否为偶数.是输出yes 否输出no

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/12 11:27:34
c语言求拆分4位数,使各位数相加,判断是否为偶数.是输出yes 否输出no
c语言求拆分4位数,使各位数相加,判断是否为偶数.是输出yes 否输出no
#include
#include
int main()
{
int a,b,c,d,e;
printf("Please input a 4 bit number:");
scanf("%d",&a);
b = a/1000;//千位
c = a%1000/100; //百位
d = a%100/10; //十位
e = a%10;//个位
if((b+c+d+e)%2 == 0)
printf("yes\n");
else
printf("NO\n");
}