I need to write a for loop but i am confused. The while loop follows:
int factorial (int n)
{
int product = 1;
while (n > 0)
{
product = n * product;
n--;
}
return product;
}
I am thinking
for (int n = 0; n > 0; n--)
{
product = n * product;
cout << product << endl;
}

New Topic/Question
Reply




MultiQuote





|