Infinite Reaction

Hi... I was trying to create a programm that writes all numbers that are multiples of 3 and 5 but when I run it, the result is infinite... and I can't find the mistake... help pls...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include "stdafx.h"
#include <iostream>

int main()
{
	using namespace std;

	for ( int nX3 = 3 , nX5 = 5 , nCount3 = 1, nCount5 = 1; (nX3 * nCount3) << 1000 && (nX5 * nCount5) << 1000; nCount3++, nCount5++)
		cout << nX3 * nCount3 << " " << nX5 * nCount5 ;
	
	system("pause");
	return 0;
}
Pay attention to the difference of
3 << 1000
and
3 < 1000

One is left bitshift and the other is less than relation.


Edit: Oh, there is of course that ostream & stream::operator<<( int ) too, but not in the condition.
Last edited on
Topic archived. No new replies allowed.