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

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 06:08:52
write a program to read a four digit integer and print the sum of its digits.Hint :Use / and % operators.
xn0 @jUFy?[/&14ZIĨHY;Mi*L'bkSL` 5:Š4SGPPV{?`ZPc'(%lϷ+w疅>bxAQ(-gLO;b2(Rx[r[ +YLfzOiv +{ Ch HŦ,ˏ,v:ZVYٞɶ1 >\ G3ds rgA9Ygyn c{$,E]'p

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