Question:Factorial program in c using function 

Answer 
#include<stdio.h>

int findFactorial(int);
int main(){
  int i,factorial,num;

  printf("Enter a number: ");
  scanf("%d",&num);

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

  return 0;
}

int findFactorial(int num){
    int i,f=1;

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

     return f;
}
Sample output: Enter a number: 8 Factorial of 8 is: 40320 

+ ExplanationNot Moderated
+ Report
Total Preview: 601
Factorial program in c using function
Copyright © 2024. Powered by Intellect Software Ltd