1 Answers
Here the code and output for Niven number:
#include <stdio.h>
int main()
{
int n, digit, sum=0, result=0, num;
printf(“Enter the number”);
scanf(“%d”, & n);
num = n;
while(num !=0)
{
digit = num % 10;
sum = sum + digit;
num = num/10;
}
result= n / sum;
printf(“Result is %d”, result);
return 0;
}
Output:
Enter the number 22
Result is 5