Problem: Write a C program to check whether a number is a Harshad Number or not.

Harshad number (or Niven) is an integer that is divisible by the sum of its digits.

Example: – 21, 111, 153.

Steps to check Harshad Number in C:

  1. Take a number as input.
  2. Sum the digits of the number.
  3. Find the remainder of number/sum i.e number%sum
  4. If the remainder is 0 then the input is Harshad number.
  5. Else Not.

Here is the implementation of the steps in C.

Output

In this tutorial, we learned to check Harshad Number in C.

Leave a Reply