A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C++ to find the factorial of a number
Q:

Write a program in C++ to find the factorial of a number

0

Write a program in C++ to find the factorial of a number

Sample Output:

 Find the factorial of a number:                                       
------------------------------------                                   
 Input a number to find the factorial: 5                               
 The factorial of the given number is: 120 

All Answers

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

#include <iostream>
using namespace std;
int main()
{
    int num1,factorial=1;
    cout << "\n\n Find the factorial of a number:\n";
	cout << "------------------------------------\n";
	cout << " Input a number to find the factorial: ";
	cin>> num1;
    for(int a=1;a<=num1;a++)
    {
        factorial=factorial*a;
    }
	cout<<" The factorial of the given number is: "<<factorial<<endl;
    return 0;
}

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now