//this is a program to find the sum of digits of the number entered by the user
#include<stdio.h>
#include<conio.h>
int sumofdigits(int num);
void main()
{
int x, sum;
printf("\n\nEnter any Number having digit more the 2 digits: ");
scanf("%d",&x);
sum = sumofdigits(x);//<-function call
printf("\n\nThe sum of digits= %d",sum);
getch();
}
int sumofdigits(int num)
{
int i,rem,sum=0;
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
return sum;
}
#include<stdio.h>
#include<conio.h>
int sumofdigits(int num);
void main()
{
int x, sum;
printf("\n\nEnter any Number having digit more the 2 digits: ");
scanf("%d",&x);
sum = sumofdigits(x);//<-function call
printf("\n\nThe sum of digits= %d",sum);
getch();
}
int sumofdigits(int num)
{
int i,rem,sum=0;
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
return sum;
}