Menu
 

program to check for strong number in c

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

Post a Comment

 
Top