Q:

C++ program to find factorial of a number

0

C++ program to find factorial of a number

In this program, we will learn how to find factorial of a given number using C++ program? Here, we will implement this program with and without using user define function.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to find factorial using loop in C++

#include <iostream>
using namespace std;

int main()
{	
	int num,i;
	long int fact=1;
	
	cout<<"Enter an integer number: ";
	cin>>num;
	
	for(i=num;i>=1;i--)
		fact=fact*i;
	
	cout<<"Factorial of "<<num<<" is = "<<fact<<endl;
	
	return 0;
}

Output

Enter an integer number: 6
Factorial of 6 is = 720

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Most popular and Searched C++ solved programs with Explanation and Output

Similar questions


need a help?


find thousands of online teachers now
C++ program to check prime number... >>
<< C++ program to display name and age...