C program for factorial of a number?
Answers
Answered by
5
Here is your program to find factorial of a number.
#include<stdio.h>
#include<conio.h>
void main( )
{
int i, n, fact;
clrscr( );
printf("Enter the value of n");
scanf("%d", &n);
fact=1;
for(i=n ; i >=1; i--)
fact=fact*i;
printf("The factorial of %d is %d",n, fact);
getch( );
}
#include<stdio.h>
#include<conio.h>
void main( )
{
int i, n, fact;
clrscr( );
printf("Enter the value of n");
scanf("%d", &n);
fact=1;
for(i=n ; i >=1; i--)
fact=fact*i;
printf("The factorial of %d is %d",n, fact);
getch( );
}
Answered by
0
Answer:
#include <stdio.h>
int main()
{
int fact = 1;
int num;
printf("Enter the number:");
scanf("%i" , &num);
for(int i = 0; i < num; i++)
{
fact = fact * (i+1);
}
printf("The factorial is %i " , fact);
return 0;
}
Explanation:
Similar questions