P032.c (630B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* WAP to input a number and check whether it is a Niven number 8 or not. (When a number is divisible by its sum of digit) e.g. : n = 126*/ 9 10 #include <stdio.h> 11 int main() 12 { 13 int n, temp, sod = 0; 14 printf("Enter the number : "); 15 scanf("%d", &n); 16 temp = n; 17 while (temp > 0) 18 { 19 sod = sod + (temp % 10); 20 temp = temp / 10; 21 } 22 if (n % sod == 0) 23 printf("\nIt is Niven number."); 24 else 25 printf("\nIt is not a Niven number."); 26 return 0; 27 }