Write a program which finds the factorial of a number entered by the user. (check for all conditions) (Beginner).
Hi,
My knowledge about C++ and programming so far is 27 youtube videos. It took me 1,5 hours to figure out and write this :)
int main()
{
int x = 1;
int number;
cin >> number;
int factorial = number;
while (x != number){
factorial = factorial * (number - x);
x++;
}
cout << "Factorial is " << factorial << endl;
}