int soChuSo(int n){
if(n==0)
return 0;
return 1+soChuSo(n/10);
}
int tongChuSo(int n){
if(n>0)
return n%10+tongChuSo(n/10);
return 0;
}
int main(){
int n;
printf("Nhap so nguyen n: ");
scanf("%d",&n);
printf("So n co %d chu so\n",soChuSo(n));
printf("Tong cac chu so cua n la: %d\n",tongChuSo(n));
return 0;
}
i have a some problems anyones help mee :(((
include
int soChuSo(int n){ if(n==0) return 0; return 1+soChuSo(n/10); }
int tongChuSo(int n){ if(n>0) return n%10+tongChuSo(n/10); return 0; }
int main(){ int n; printf("Nhap so nguyen n: "); scanf("%d",&n); printf("So n co %d chu so\n",soChuSo(n)); printf("Tong cac chu so cua n la: %d\n",tongChuSo(n)); return 0; }
Originally posted by @hoang1904 in https://github.com/kriscross07/atom-gpp-compiler/issues/243#issuecomment-1041564239