[Bug c++/57842] New: for statement not terminating properly
groundup2360917182914017 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Jul 7 16:07:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57842
Bug ID: 57842
Summary: for statement not terminating properly
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: groundup2360917182914017 at gmail dot com
In the program below. If I enter 0 through 10 it should print
0
1
2
3
4
5
6
7
8
9
10
But it doesn't. I think what it print is a error.
0
1
2
3
4
5
6
7
8
9
10
10
11
Source Code is
#include <iostream>
int main()
{
int number1, number2;
std::cout << "Enter two numbers to print the numbers between: ";
std::cin >> number1 >> number2;
if(number1 < number2)
{
for(; number1 <= number2; number1++)
{
std::cout << number1 << std::endl;
}
}
if(number1 > number2)
{
for(; number2 <= number1; number2++)
{
std::cout << number2 << std::endl;
}
}
if(number1 == number2)
{
std::cout << number1 << std::endl;
}
return 0;
}
More information about the Gcc-bugs
mailing list