Answers for "c++ factorial program without function"

C++
1

factorial c++ without using function

#include <iostream>
using namespace std;

int main()
{
	unsigned int num; //unsigned is used for not taking negetive values.
	unsigned long long factorial = 1; //Since the factorial a number can be large, so long long data type is used.
	cout << "Give me any positive number :	";
	cin >> num;

	for (int i = 1; i <= num; i++) {
		factorial = factorial * i;
	}
	cout << "Factorial of the given number is: " << factorial;
}
Posted by: Guest on November-07-2020

Code answers related to "c++ factorial program without function"

Browse Popular Code Answers by Language