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