C Program to check a number is strong number or not


In this program, You will learn how to check a number is strong number or not in C.


Some list of strong numbers is : 1, 2, 145


Example: How to check a number is strong number or not in C

Run it Now
#include<stdio.h>

int main() {

   int n, t, r, i, f, s = 0;

   printf("Enter a Number :");
   scanf("%d", &n);

   t = n;
   while (n > 0) {
       f = 1;
       r = n % 10;
       for (i = 1; i <= r; i++) {
           f = f * i;
       }
       s = s + f;
       n = n / 10;
   }

   if (s == t) {
       printf("\nIt is a Strong Number :%d", t);
   } else {
       printf("\nIt is Not a Strong Number :%d", t);
   }

   return 0;
}

Output:

Enter a Number :145
It is a Strong Number :145