Find-Sum-Of-Digits-And-Factorial-Of-Number

Menu-driven program to find Factorial and Sum of digits

C

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 |

Also Read – Quadratic Equations Program

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");
        printf("\n\nYour Choice? : ");
        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

Your Choice? : 1

Enter a number to calculate it's factorial
3

Factorial of 3 = 6

1. Factorial
2. Sum of Digits
3. Exit

Your Choice? : 2

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

Your Choice? :

Friends Mujhe Umeed Hai Ki Aapko C Language program to find Factorial and Sum of digits In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

MasterPrograming Apps

Leave a Reply

Your email address will not be published. Required fields are marked *