From a7698eba6805988723b58a622be3ecf8e8e84bf3 Mon Sep 17 00:00:00 2001 From: MohamedSabthar <43032716+MohamedSabthar@users.noreply.github.com> Date: Mon, 28 Oct 2019 22:00:05 +0530 Subject: [PATCH] Create Sum of Digits of a Five Digit Number.c --- C/Sum of Digits of a Five Digit Number.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 C/Sum of Digits of a Five Digit Number.c 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; +}