bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

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 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror