
Originally Posted by
quixomatic
Just once per while loop
If that were true, then this C++ program:
Code:
#include <iostream>
int main()
{
int n = 5;
for (int count = 1; count < n; count++)
{
int count2 = 1;
while (count2 < count)
{
count2 = count2 * 2;
std::cout << count2 << ' ';
}
}
std::cout << std::endl;
}
would have the exact same output as this C++ program:
Code:
#include <iostream>
int main()
{
int n = 5;
for (int count = 1; count < n; count++)
{
int count2 = 1;
if (count2 < count)
{
count2 = count2 * 2;
std::cout << count2 << ' ';
}
}
std::cout << std::endl;
}
However, the former gives me the output:
and the latter gives me the output:
Clearly, your statement must be wrong.