Answers for "function for factorial c"

C
0

factorial c program using for loop

#include<stdio.h>
int main(){
  int i,f=1,num;
 
  printf("Enter a number: ");
  scanf("%d",&num);
 
  for(i=1;i<=num;i++)
      f=f*i;
 
  printf("Factorial of %d is: %d",num,f);
  return 0;
}
Posted by: Guest on January-10-2021
1

factorial program in c using function

#include <stdio.h>

int fact (num1);

void main ()
{
    int num,ret;
    
    printf ("Enter the number: ");
    scanf("%d",&num);

    ret = fact(num);

    printf("nthe factorial of %d is %dn",num,ret);

}

int fact(num1)
{
    int i, f=1;

    for(i=1; i<=num1; i++)
    {
        f = f * i;
    }

    return f;
}
Posted by: Guest on June-23-2021

Code answers related to "function for factorial c"

Code answers related to "C"

Browse Popular Code Answers by Language