Follow Us

LightBlog

Breaking

Saturday, February 4, 2017

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

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

      #include<stdio.h>
      #include<conio.h>
       int main()
          {
             int num,i,f,r,sum=0,t;

              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==t)
           printf("%d is a strong number",t);
       else
           printf("%d is not a strong number",t);

       return 0;
    }

Sample output:
Enter a number: 145
145 is a strong number

No comments:

Post a Comment