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

C for loop factorial value (incrementation)

#include<stdio.h>
main()
{
    int n,f,i;
    printf("Enter a number: ");
    scanf("%d",&n);
        printf("
");
        printf("Formula: ");
    f=1;
        for(i=1;i<n;i++)
        {
    	    printf("%d*",i);
    	    f=f*i;
        }
            f=f*i;
            printf("%d",i);
                printf("
The factorial value: %d",f);
}
Comment

C for loop factorial value (decrementation)

//for loop factorial value
#include <stdio.h>
main()
{
    int n,f,d;
    f=1;
    printf("
Enter a number: ");
    scanf("%d",&n);
    for(d=n;d>1;d--)
    {
    	printf("%d*",d);
        f=f*d;
    }
    printf("%d",d);
    printf("

The factorial value: %d",f);
}
Comment

PREVIOUS NEXT
Code Example
C :: find factors of a number in c 
C :: how to print something out to the console c 
C :: arduino serial read write structure 
C :: c program hide console window 
C :: div en langage c 
C :: convert string to float c 
C :: how to print boolean in c 
C :: come creare variabili casuali in c 
C :: c boolean 
C :: yourkill071 
C :: is it possible to access argv in function 
C :: successeur ("123") 
C :: libdvd-pkg: `apt-get check` failed 
C :: nested loop in c 
C :: servo motor arduino 
C :: how to turn off zsh 
C :: c static variables 
C :: take long long input in c 
C :: typedef in c 
C :: bash while loop n times 
C :: fgets function in c 
C :: binary tree in c search 
C :: sqlserver insert with set identity 
C :: c code to grade marks 
C :: c check if character is a space 
C :: print to console in c 
C :: c print 
C :: how to select numeric columns in r 
C :: c structure with pointer 
C :: c char to int 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =