Programming C : Find out the factorial value of a number N. Where N will come from keyboard.

Programming C : Find out the factorial value of a number N. Where N will come from keyboard.

Programming C

Problem : Find out the factorial of a number N. Where N will come from keyboard.

/*
Author : Sabya Roy
*/

 
#include<stdio.h>
#include<conio.h>
main ()
{
              int n, i;                                                                                    //Taking Variables
              unsigned long long factorial=1;                                         //Taking variable for factorial
              printf(“Enter an integer number : “);                               //Show a dialog
              scanf(“%d”, &n);                                                                   //Input the number that want the factorial value
              if (n<0)
              {
                            printf(“Error! There in no factorial value of negative numbers.”);
              }
              else
              for (i=1; i<=n; i++)                                                               //Condition and loop for factorial
              {
                            factorial *= i;                                                            //Controller for factorial value
              }
              printf(“Factorial value of %d is %llu”, n, factorial);      //Show the answer
              getch();
}

———————————————————————————————————————————————————-




Output :

Enter an integer number : 5
Factorial value of 5 is 120

———————————————————————————————————————————————————-

Share this post

Comments (63)

Leave a Reply

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