C program -  How to check given number is strong number or not

#include<stdio.h>
int main(){
  int num,i,f,r,sum=0,temp;
 
  printf("Enter a number: ");
  scanf("%d",&num);
 
  temp=num;
  while(num){
      i=1,f=1;
      r=num%10;
 
      while(i<=r){
         f=f*i;
        i++;
      }
      sum=sum+f;
      num=num/10;
  }
  if(sum==temp)
      printf("%d is a strong number",temp);
  else
      printf("%d is not a strong number",temp);
 
  return 0;
}

Output: 

C programming, C examples, C programs, strong number in c


07 Aug 2015

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top