## Write a c program to check that given number is a strong number or not.

What is Storng Number?

Strong number is a number whose sum of the factorial of digits of number is equal to given number.

For Example :

145 is a strong number.

Let's Check this number is strong number or not.

1! + 4! + 5! = 1 + 24 + 120 = 145.

So 145 is a Strong number.

Let's code...

``````#include<stdio.h>

int factorial(int i);
int main(){

int n;
printf("Enter the Number : ");
scanf("%d", &n);
int temp = n, sum = 0;
while(temp>0){
int digit = temp%10;
sum = sum + factorial(digit);
temp = temp / 10;
}

if(sum == n){
printf("%d is a Strong Number", n);
}else{
printf("%d is not Strong Number", n);
}
return 0;
}

int factorial(int i){
int fact = 1;
for(int j=1; j<=i; j++){
fact = fact * j;
}
return fact;
}
``````

Output :

Enter the Number : 145
145 is a Strong Number

How it's work?

Step 1 : Start the program

Step 2 : Include header file "stdio.h"

Step 3 : Declare a function (for calculate the factorial)

Step 4 : Start main() function

Step 5 : Initilized a variable n, which store the given number by user for checking the strong number.

Step 6 : Print message for user.

Step 7 : Take input from scanf() function.

Step 8 : Initilized another variable temp and sum , temp is used for temparory variable which store the original number and sum is used for store the ans whose initial assigned zeor(0).

Step 9 : Start a while loop, and here given the condition when ( temp > 0 ) , when condition is true then execute the loop body statement Repeate all (Step10, 11, 12).

Step 10 : Initilized a varialbe digit , whose store the last digit of the number.

Step 11 : Execute this sum = sum + factorial(digit);

When factorial(digit) is called then go to the this function defination.

Step 12 : Remove the last digit , with the help of this ( temp = temp / 10 ).

Step 13 : Check that given number is equal to sum, if the condition is true then print given number is a Strong Number otherwise both are not equal then print given number is not a strong number.

Step 14 : return 0 (Exit).

Explain the factorial function :

In factorial function , initilized a variable fact and assigned the value 1. Start for loop , in for loop we initilized a variable j = 1 and the condition is j<=i and increament the value of j by 1. And perform the operation after goes to loop body this expression ( fact = fact * j). When loop is terminated. then we return the value of fact.

Thanks...

## Neon Number | c programming language

A neon number is a number if the sum of the square of that number is equal to the actual number, then it is a neon number. For Example : 9 is a neon number.

## C programming restaurant menu code | @lapmos

In this tutorial we write a c program which print the menus of restaurant with product and price.

## Primary Arithmetic program in c programming and cpp programming language

Write a c and c++ programming language , primary Arithmetic Program

## Automorphic Number | C programming language | @lapmos

An automorphic number is a number that has the same digit at the end of the square as the given number is an automorphic number. For Example : 25 is a Automorphic Number.

## 9 basic program in cpp programming language | @lapmos

In this post we write the 9 basic program in c programming language which is based the basic understanding of c++ programming language.

## Spy Number | c programming

Today we are going to write a program which is to check if given number is spy or not and yes the most important thing is what is spy number, you will get the answer of all these on this blog.