Sunday, 24 December 2017

Program to check given number is Strong number or not

#include<stdio.h>
int fac(int k);
int main( )
{
    int n, j, i, num=0, sum=0;
    
    printf("Enter a number");
    scanf("%d",&n);

    j=n;


    while(n>0)

     {
         i=n%10;
         n=n/10;
         sum=fac(i);
         num=num+sum;
     }

if(num==j)

   printf("%d is strong number",j);

else

   printf("%d is not strong number",j);

return 0;

}

int fac(int k)

{
    if(k==0 || k==1)
        return 1;
    else
      return(k*fac(k-1));
}

   

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...