C program to find a strong number.

 

01 #include<stdio.h>
02
03 int main()
04 {
05 int num,i,p,r,sum=0,save_num;
06 printf("Enter a number");
07 scanf("%d",&num);
08 save_num=num;
09
10 while(num)
11 {
12 i=1,p=1;
13 r=num%10;
14
15 while(i<=r)
16 {
17 p=p*i;
18 i++;
19 } //while
20
21 sum=sum+p;
22 num=num/10;
23 } //while
24
25 if(sum==save_num)
26 printf("%d is a Strong number", save_num);
27 else
28 printf("%d is not a Strong number", save_num);
29
30 return 0;
31 }
 
 OUTPUT :

(1st Run)

Enter a number 145
145 is a Strong number


(2nd Run)

Enter a number 131
131 is not a Strong number

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.