Skip to content

Instantly share code, notes, and snippets.

@CSElliyas
Created November 26, 2016 03:52
Show Gist options
  • Save CSElliyas/8a8e5c04b8fdeb8f48f35b40867cdb19 to your computer and use it in GitHub Desktop.
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
/*
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