diff --git a/C/Sum of Digits of a Five Digit Number.c b/C/Sum of Digits of a Five Digit Number.c new file mode 100644 index 0000000..2ca0789 --- /dev/null +++ b/C/Sum of Digits of a Five Digit Number.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +int main() { + + int n; + scanf("%d", &n); + int digit, temp, sum = 0; + temp = n; + //Complete the code to calculate the sum of the five digits on n. + while(temp > 0) + { + digit = temp % 10; + sum = sum + digit; + temp = temp / 10; + } + printf("%d\n",sum); + return 0; +}