write a program to read a four digit integer and print the sum of its digits.Hint :Use / and % operators.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 09:08:37
writeaprogramtoreadafourdigitintegerandprintthesumofitsdigits.Hint:Use/and%operators.writeaprogramto
write a program to read a four digit integer and print the sum of its digits.Hint :Use / and % operators.
write a program to read a four digit integer and print the sum of its digits.
Hint :Use / and % operators.
write a program to read a four digit integer and print the sum of its digits.Hint :Use / and % operators.
#include<stdio.h>
int main()
{
\x05int a,b,c,d,num;
\x05printf("please input a num between 1000~9999!\n");
\x05scanf("%d",&num);
\x05a=num/1000;
\x05b=num/100%10;
\x05c=num/10%10;
\x05d=num%10;
\x05printf("%d\n",a+b+c+d);
}
accept please!thanks