#include <stdio.h> int fun(int a) { int sum=0; while(a>0) { sum=sum+a%10; a=a/10; } return sum; } main() { int a,b; printf("please input a number:"); scanf("%d",&a); b=fun(a); printf("%d",b); }