Skip to content

Instantly share code, notes, and snippets.

@MaratB
Created September 22, 2013 21:28
Show Gist options
  • Save MaratB/6663996 to your computer and use it in GitHub Desktop.
Save MaratB/6663996 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <conio.h>
int Summa(int N)
{
int d,sum=0;
while(N!=0)
{
d=N%10;
sum=sum+d;
N=N/10;
}
return sum;
}
main()
{
int N,S;
printf("Enter integer to find the sum of its digits: \n");
scanf("%d", N);
S=Summa(N);
printf("Sum of digints is %d", S);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment