Let\'s say I have an integer called \'score\', that looks like this:
int score = 1529587;
Now what I want to do is get each digit 1, 5, 2,
I've made this solution, it-s simple instead read an integer, i read a string (char array in C), then write with a for bucle, the code also write the sum of digits
// #include
scanf("%s", n);
int total = 0;
for (int i = 0; i< strlen(n); i++){
printf("%c", n[i]);
total += (int)(n[i]) -48;
}
printf("%d", total);