C program to calculate factorial of number

C program to calculate factorial of number

563
6
SHARE

C program to calculate factorial of number using recursion which accepts the number from the user as input of which Factorial has be calculated and return the output obtained by calculation factorial of a number. Lets us how to code of a number n.

C program to calculate factorial of number

C Program to calculate Factorial of Number N :

# include <stdio.h>
# include <conio.h>
# include <math.h>
float getex(double);
main()
{
 int i,n;
 double s=0.0,a,b;
 clrscr();
 printf("*** Factorial Calculator *** \n.:: C Code Champ \n--------------------------------\n");
 printf("Please enter N to Calculate N! :");
 scanf("%d",&n);
 if (n>=0)
 {
  printf("\nPlease wait , calculating ...\n");
 // calculating s = Siq (i=1 to n) [ Log i ]
   for (i=1;i<=n;i++)
        s+=log10(i);
        b = floor(s);
 // End of Calculating S
    a = getex(s-b);
    printf("\n\n\n   Result: %d!  ~=  %5.4f e+%d\n\n-----------\n",n,a,(int)(b));
    printf("[[[   Please enter any key to exit ...   ]]]");
 }

 else
  {
     clrscr();
     printf("Invalid argument found ,\n [[[   please enter any key to exit ... ]]]");
  }
 getch();

}
float getex(double p)
{
 float r;
   r = pow(10,p);
 return r;
}

I hope you all have enjoyed the . If you face any issues with code just write your queries in comments below.

If you like our codes and be a part of . Join us a Google+ and Facebook.

 

6 COMMENTS

  1. You actually make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post, I will try to get the hang of it!

  2. Woman of Alien…

    Ideal get the job done you’ve got done, this great site is de facto neat with excellent info. Time is God’s means of trying to keep every little thing from happening simultaneously….

  3. A vacuum-cleaner is the most effective of cleansing tools; it can also be the more expensive.
    There are several different kinds of vacuum with many different characteristics.
    So before purchasing a premier hoover ensure you understand which kind of vacuum-cleaner
    is best for your requirements.

    Picking the best vacuum-cleaner might be perplexing.
    To make points better you should know what the different
    kinds of vacuum are, what the primary attributes it is possible to find on a vacuum-cleaner, and want you type of flooring
    you’re going to be employing a vacuum-cleaner on.

LEAVE A REPLY