Write a c++ program to whether check given number is strong number or not.





Write a c++ program to whether check given number is strong number or not.


#include<iostream>
int main(){
  int num,i,f,r,sum=0,temp;

  cout << "Enter a number: ";
  cin >> 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)
     cout << temp << " is a strong number";
  else
     cout << temp << " is not a strong number";

  return 0;
}





1 comment:

Unknown said...

can i get a blog for oops concept aswell