Open main menu
Projects
/
Calculate Factorial of a Number
Close menu
Login
Home
Tools
Source
Process
Command Line
About us
Help & Support
Terms & Conditions
Privacy Policy
Project Settings
Close modal
Project Title
Auto Save
Update Settings
main.cpp
Output
main.cpp
Output
Check icon
Compiler Connected
Close
Error icon
Compiler Error. Please try again later.
Close
Warning icon
Compiler Connecting...
#include
using namespace std; int main() { int num; unsigned long long factorial = 1; // Get the number for which you want to calculate the factorial cout << "Enter a non-negative integer: "; cin >> num; // Calculate the factorial for (int i = 1; i <= num; ++i) { factorial *= i; } cout << "Factorial of " << num << " = " << factorial << endl; return 0; }