Pages

Saturday 2 February 2019

STRONG NUMBERS IN BETWEEN MIN AND MAX VALUES

// program to illustrate strong number in between min and max values

#include<stdio.h>
void main()
{
  int min,max,n,i,r,sum=0,temp,fact;
  printf("\nEnter min value:");
  scanf("%d",&min);
  printf("\nEnter max value:");
  scanf("%d",&max);
  printf("\nStrong numbers are:");
   for(n=min ;n<=max;n++)
   {
     temp=n,sum=0;
     while(temp)
     {
       i=1,fact=1;
       r=temp %10;
         while(i <= r)
          {
           fact = fact * i; 
           i++;
          }
        sum=sum +fact;
        temp = temp /10;
     }
     if(sum==n)
       printf("\n %d is a strong number \n",n);
   }
}

output:


No comments:

Post a Comment

Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...