#include<stdio.h>

int sumofdigits(int n)

{

int sum=0;

while(n!=0)

{

sum+=(n%10);

n/=10;

}

return sum;

}

void main()

{

int n;

printf("\nEnter any number..");

scanf("%d",&n);

printf("\nThe sum of the digits of the number is..%d",sumofdigits(n));

}

int sumofdigits(int n)

{

int sum=0;

while(n!=0)

{

sum+=(n%10);

n/=10;

}

return sum;

}

void main()

{

int n;

printf("\nEnter any number..");

scanf("%d",&n);

printf("\nThe sum of the digits of the number is..%d",sumofdigits(n));

}

## No comments:

## Post a comment