First of all, hello everyone. My problem is this. In writing a program which accepts multiple user inputs of type int, during the first run through the program, after the first cout << statement prints, I have to press enter twice in order for the second cout statement to display. The first cin only stores the first digit of the input, which messes up the calculation. On all subsequent runs through the program, everything works fine. I've had this problem on a few programs now. When my professor compiles the programs himself, using Visual C++, everything works the way it's supposed to, but at home I use Dev C++. I've also built the program using Ultimate++ and I get the same problem. Is there something wrong with my computer setup??
#include <iostream>
using namespace std;
int main()
{
int num1 , num2 , sum , lowBound, upBound;
char repeat = 'y';
while (repeat == 'y')
{
num1 = 0;
num2 = 0;
sum = 0;
cout << "Enter the first number: ";
cin >> num1;
cout << "\nEnter the second number: ";
cin >> num2;
if (num1 >= num2)
{
upBound = num1;
lowBound = num2;
}
else
{
upBound = num2;
lowBound = num1;
}
for( int i = lowBound; i <= upBound; i++ )
{
sum += i;
}
cout << "\nThe sum of all numbers, inclusive, between " << lowBound << " and " << upBound
<< " is " << sum << ". \n";
cout << "Would you like to play again?: ";
cin >> repeat;
}
system("Pause");
return 0;
}
edit * Thanks for pointing out my stupidity Narue, hope that's a little better :)