Monday, August 25, 2014

C Program to Display Sum of Factorial Values of All Digits in a Number



This is a C Language program which displays the sum of factorial values of all the digits in a number.

#include < stdio.h>
void main()
{
 int i,j,sum=0,c,fact,n;
 clrscr();
 printf("\nEnter the number:");
 scanf("%d",&n);
 for(i=n;i>0;i=i/10)
 {
 c=i%10;
 fact=1;
 for(j=2;j<=c;j++)
 fact=fact*j;
 sum=sum+fact;
 }
 printf("\nSum of the factorial values of all digits of %d is %d",n,sum);
  getch();
    }

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner