The while loop, Examples
int n = 0, x = 15;
while( n < x)
{
cout << n;
n = n + 1;
}
int x = 0, n = 15;
int fact = 1;
while( x < n)
{
x = x + 1;
fact = fact*x;
}
cout << fact;
First of all does n = n + 1 make sense to everyone?
Code on the left prints the integers from 0 to 14
What about n = 0; 0! Should be 1
What does the program on the right print when n= 0?