// HARSHAD Number or Not in C using For loop
// It's the main function of the program
int main()
{
int num, sum = 0;
// Step-1 Take an input from the User
printf("INPUT A NUMBER: ");
scanf("%d", &num);
// Step-2 Store the input value into another variable
int original = num;
// Step-3 Use a loop to check the Harshad number
for (original != 0; original /= 10;)
sum += original % 10;
// Step-4 Compare the input value with the sum of divisors of the input value
if (num % sum == 0)
printf("\n%d IS A HARSHAD NUMBER\n", num);
else
printf("\n%d IS NOT A HARSHAD NUMBER\n", num);
return 0;
}