#include<stdio.h>
int sum_digit(int);
int main()
{
int a;
printf("Enter no. for which we want the sum of digits\n");
scanf(" %d", &a);
printf("Some of digit %d", sum_digit(a));
return 0;
}
int sum_digit(int num)
{
int sum = 0;
while(num > 0);
{
sum = sum + num % 10;
num = num / 10;
}
}
When I run this code it asks for value but as I hit enter it gets stuck. Not able to understand why it is not producing any results.
Is this the problem of whites spaces with scanf?