Search
 
SCRIPT & CODE EXAMPLE
 

C

factorial in c

/*
Factorial Program in C: Factorial of n is the product of all positive 
descending integers. Factorial of n is denoted by n!. 
For example:
5! = 5*4*3*2*1 = 120  
3! = 3*2*1 = 6  
*/

#include<stdio.h>  
int main()    
{    
 int i,fact=1,number;    
 printf("Enter a number: ");    
  scanf("%d",&number);    
    for(i=1;i<=number;i++){    
      fact=fact*i;    
  }    
  printf("Factorial of %d is: %d",number,fact);    
return 0;  
}   
Comment

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;
}
Comment

c program to find the factorial of a number

#include <stdio.h>
int main() {
    int n, i;
    unsigned long long fact = 1;
    printf("Enter an integer: ");
    scanf("%d", &n);

    // shows error if the user enters a negative integer
    if (n < 0)
        printf("Error! Factorial of a negative number doesn't exist.");
    else {
        for (i = 1; i <= n; ++i) {
            fact *= i;
        }
        printf("Factorial of %d = %llu", n, fact);
    }

    return 0;
}
Comment

factorial of a number in c

#include<stdio.h>
void main(){

    int num, i, mul;
    num = 5;
    mul = 1;
    for(i = 1; i <= 5; i++){
        mul = mul * i;
    }
    printf("%d",mul);

}
Comment

for any factorial numbers in c

int fact=1;
	for(int i=1;i<=100;i++)
	{
		fact=((fact%97)*(i%97))%97;
		
	}
	printf("%d
",fact);
Comment

funtion factorial c

function factorial
Comment

factorial of a number in c

factorial
Comment

PREVIOUS NEXT
Code Example
C :: c language time() function 
C :: dynamic memory in c 
C :: initialize array in c with 0 
C :: Access denied creating xampp-control.ini 
C :: limit axis in one direction plt 
C :: gcc options to find out makefiel rules 
C :: remove axis numpy array 
C :: how to make sure input is integer c 
C :: C scanf() to read a string 
C :: prime number c program 
C :: enum in c 
C :: c/c++ windows api download file 
C :: identifier bool is undefined in c 
C :: Bootstrap textarea from 
C :: check if pid exists c 
C :: c bits 
C :: number pattern in c 
C :: c change value of const 
C :: #define f_cpu 
C :: how to change file permissions in C language 
C :: c check if character is upper case 
C :: sqrt function in c 
C :: print the name of a file c 
C :: windows make clean 
C :: files in c programming 
C :: C/AL Convertion of Decimal to String/Text 
C :: C/c drop mime 
C :: get string from ptrace registery 
C :: winautomation block input not working 
C :: C if...else Statement 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =