Created
November 26, 2016 03:52
-
-
Save CSElliyas/8a8e5c04b8fdeb8f48f35b40867cdb19 to your computer and use it in GitHub Desktop.
A Program to Compute the Sum of the Digits of a Given Integer Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Program Name: Write a program to compute the sum of the digits of a given integer number. | |
Program By: Elliyas Ahmed | |
*/ | |
#include <stdio.h> | |
int main() | |
{ | |
int n, remainder, sum; | |
scanf("%d",&n); | |
sum = 0; | |
while(n!=0) | |
{ | |
remainder = n % 10; | |
sum= sum + remainder; | |
n = n / 10; | |
} | |
printf("%d\n",sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment