Hello guys.
This is my first post on the site and I think I'll like it here very much. :)
I already have the site set as my home page.
So here is my dilemma.
The program is supposed to do some pretty basic comparisons of two numbers typed in by the user and then display a series of checks to see if it's bigger, smaller or equal than the other number.
Everything runs smoothly but at the end it CMD closes way too fast. I've read that cin.get();
would allow the window to remain open until a user presses a key, but it doesn't work as intended.
Remember I'm very new to C++ so the syntax is very alien to me right now even though I've programmed a lot in C#. Getting used to it, barely. :P
Anyway, here's my code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//Begin program execution.
int main()
{
int number1;
int number2;
cout << "Enter two intergers to compare: "; //Requests user to insert two numbers.
cin >> number1 >> number2;
if ( number1 == number2 )
cout << number1 << " is equal to " << number2 << endl;
if ( number1 != number2 )
cout << number1 << " is not equal to " << number2 << endl;
if ( number1 < number2 )
cout << number1 << " is less than " << number2 << endl;
if ( number1 > number2 )
cout << number1 << " is greater than " << number2 << endl;
if ( number1 <= number2 )
cout << number1 << " is less or equal than " << number2 << endl;
if (number1 >= number2 )
cout << number1 << " is greater or equal than " << number2 <<endl;
cin.get(); //<----- This is where it should stay open.
return 0; // indicate that program ended successfully
}