write a program to read a four digit integer and print the sum of its digits.Hint :Use / and % operators.

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/13 01:19:22
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.

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