Write a C function called Sumdigits that accepts an integer
Write a C function, called Sumdigits that accepts an integer value and returns the sum of the individual digits.
Solution
#include <stdio.h>
#include <conio.h>
void main()
{
int number,sumofdigits;
clrscr();
printf(\"Enter any integer value: \");
scanf (\"%d\", &number);
sumofdigits=Sumdigits(number);
printf(\"The sum of digits of the given integer number=%d\",sumofdigits);
getch();
}
int Sumdigits (int number)
{
int num;
int summation=0;
num=number;
do
{
summation = summation + num % 10;
num = num / 10;
} while (num > 0);
return summation;
}

