# Menu-driven program to find Factorial and Sum of digits

Menu-driven C program to find Factorial and Sum of digits – C Programming Me Ham Menu Driven Program Ko Create Karne Wale Hai, Jo Ye Program Switch Case Se Banayenge Or Isme Ham Find Factorial Or Sum Of Digits Find Karenge |

## C Program to find Factorial and Sum of digits

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Example 1:

```#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
int choice;
int i,n,fact = 1,sum=0,d;
do
{
printf("\n1. Factorial");
printf("\n2. Sum of digits");
printf("\n3. Exit");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter a number to calculate it's factorial\n");
scanf("%d", &n);
for (i= 1; i <= n; i++)
fact = fact * i;
printf("Factorial of %d = %d\n", n, fact);
break;
case 2:
printf("\nEnter a Number to find the sum of digits : ");
scanf("%d",&n);
sum=0;
while(n>0)
{
d=n%10;
sum=sum+d;
n=n/10;
}
printf("\nThe sum of digits of the number is %d ",sum);
break;
default:
exit(0);
}
}
while(1);
getch();
}```

Output:

```1. Factorial
2. Sum of Digits
3. Exit

Enter a number to calculate it's factorial
3

Factorial of 3 = 6

1. Factorial
2. Sum of Digits
3. Exit

Enter a Number to find the sum of digits : 4 5

The sum of digits of the number is 9

1. Factorial
2. Sum of Digits
3. Exit