This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57842] New: for statement not terminating properly
- From: "groundup2360917182914017 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 07 Jul 2013 16:07:01 +0000
- Subject: [Bug c++/57842] New: for statement not terminating properly
- Auto-submitted: auto-generated
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;
}