Here, we have a basic program example to calculate the factorial of a number using different languages. The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. This program is created in c language, c++, Java, and Python.
Code to calculate factorial in C language
#include <stdio.h>
void main(){
  int i,f=1,num;
  printf("Input the number : ");
  scanf("%d",&num);
  for(i=1;i<=num;i++)
      f=f*i;
  printf("The Factorial of %d is: %d\n",num,f);
}
Code to calculate factorial in C++ language
#include <iostream>
using namespace std;
int main()
{
    int i,f=1,num;
    cout << "Input the number : ";
    cin >> num;
   for(i=1;i<=num;i++)
      f=f*i;
  cout<<"The Factorial of "<<num<<" is: "<<f;
}
Code to calculate factorial in Python language
f=1
num = int(input("Input the number: "))
for i in range(1, num+1):
    f=f*i
print("The factorial of ", num," is:", f)
Code to calculate factorial in Java language
import java.util.*;
public class factorial {
    public static void main(String[] args) {     
        int i,f=1,num;
	System.out.println("Enter a positive integer:  ");
        Scanner s=new Scanner(System.in);
        num = s.nextInt();
        for(i=1;i<=num;i++)
        f=f*i;
        System.out.println("The Factorial of " + num + " is: " + f );
      }
}
