Pages

Showing posts with label PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS STRONG OR NOT. Show all posts
Showing posts with label PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS STRONG OR NOT. Show all posts

Saturday, 2 February 2019

PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS STRONG OR NOT

A NUMBER IS CALLED STRONG NUMBER IF SUM OF THE FACTORIAL OF ITS DIGIT IS EQUAL TO NUMBER ITSELF
FOR EXAMPLE: 145
I FACTORIAL IS 1
4 FACTORIAL IS 24
5 FACTORIAL IS 120
THEREFORE 1 + 24 +120 =  145 

PROGRAM:

 // prg to illustrate strong number

#include<stdio.h>

void main()
{
 int n,i,r,sum=0,temp,fact;
 printf("enter any number:");
 scanf("%d",&n);
 temp=n;
 while(n != 0)
  {
   i=1,fact=1;
   r=n %10;
   while(i <= r)
     {
      fact = fact * i;
      i++;
     }
     sum=sum +fact;
     n = n /10;
  }
  if(sum==temp)
    printf("%d is a strong number \n",temp);
  else
    printf("%d is not a strong number \n",temp);
}

output:


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...