Factorial in C using Character array

Hey Guys, wondering why I am here once again with this “factorial” thing? You will get to know it in no time..just keep reading! Let’s calculate some of the factorials: 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 well there is no problem, isn’t it? Continue then… 7! = 5040 8! = 40320 Now let’s look at 21! It is 51090942171709440000...

June 15, 2016 · 5 min · Swati Kesarwani

Factorial in C

Hey! Today i am gonna show you how to calculate factorial of a number. The code below depicts the basic methodology of how to calculate factorial of a number. # include<stdio.h> void factorial(int number){ int i; long long int factorial=1; for ( i = number ; i > 0 ; i-- ) factorial*=i; // Printing the factorial of the number **/ printf("Factorial of %d = %lld",number,factorial); return 0; } int main(){ // Declaring variables **/ int num; // Asking and scanning input **/ printf("Enter a number : "); scanf("%d",&num); // Passing number to the function **/ factorial(num); return 0; } output of above code will be...

June 1, 2016 · 1 min · Swati Kesarwani