Computer Science, asked by Oyasco355, 10 months ago

Write A Program In C To Find The Factorial Of A Given Number Using Pointers.

Answers

Answered by chanalex132
4

Answer:

#include<stdio.h>

 

void findFactorial(int,int *);

int main()

{

int i,factorial,num;

 

printf("Enter a number: ");

scanf("%d",&num);

 

findFactorial(num,&factorial);

printf("Factorial of %d is: %d",num,*factorial);

 

return 0;

}

 

void findFactorial(int num,int *factorial)

{

int i;

 

*factorial =1;

 

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

*factorial=*factorial*i;

}

Explanation:

Result :

Enter a number: 5

Factorial of 8 is: 120

Similar questions