P032.c (494B)
1 /* WAP to input a number and check whether it is a Niven number 2 or not. (When a number is divisible by its sum of digit) e.g. : n = 126*/ 3 4 #include <stdio.h> 5 int main() 6 { 7 int n, temp, sod = 0; 8 printf("Enter the number : "); 9 scanf("%d", &n); 10 temp = n; 11 while (temp > 0) 12 { 13 sod = sod + (temp % 10); 14 temp = temp / 10; 15 } 16 if (n % sod == 0) 17 printf("\nIt is Niven number."); 18 else 19 printf("\nIt is not a Niven number."); 20 return 0; 21 }