Factorial is a mathematical way of multiplying the numbers.
4! => 4 x 3 x 2 x 1 => 24
10 ! => 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 => 3628800
#include<stdio.h>
int main()
{
int i,factorial=1,input;
printf("Enter a number to Find Factorial?");
scanf("%d",&input);
for(i=1; i<=input; i++){
factorial=factorial*i;
}
printf("Factorial of %d is: %d",input,factorial);
return 0;
}
Output:
Enter a number to Find Factorial?10
Factorial of 10 is: 3628800
Enter a number to Find Factorial?5
Factorial of 5 is: 120
4! => 4 x 3 x 2 x 1 => 24
10 ! => 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 => 3628800
#include<stdio.h>
int main()
{
int i,factorial=1,input;
printf("Enter a number to Find Factorial?");
scanf("%d",&input);
for(i=1; i<=input; i++){
factorial=factorial*i;
}
printf("Factorial of %d is: %d",input,factorial);
return 0;
}
Output:
Enter a number to Find Factorial?10
Factorial of 10 is: 3628800
Enter a number to Find Factorial?5
Factorial of 5 is: 120
No comments:
Post a Comment