google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to find the factorial of a number using function - 2nd puc computer science

Write a c program to find the factorial of a number using function

Write a c program to find the factorial of a number using function

write a program to find the factorial of a number using function in c

#include<stdio.h>

#include<conio.h>

void main()

{

int factorial(int);

int n,fact;

clrscr();

printf("Enter the number: ");

scanf("%d",&n);

fact=factorial(n);

printf("%d!=%d",n,fact);

getch();

}

int factorial(int n)

{

int f=1,i;

for(i=1;i<=n;i++)

f=f*i;

return(f);

}

Output:

Enter the number: 3

3!=6 
Write a c program to find the factorial of a number using function Write a c program to find the factorial of a number using function Reviewed by Vision Academy on December 13, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.