#include<iostream.h>
#include<conio.h>
int main()
{
int x, y;
clrscr();
cout<<"Enter two numbers separated by a space:";
cout<<endl;
cin>>x;
cout<<endl;
cin>>y;
cout<<"The larger number is: ";
{
if (x>y)
cout<<x;
else
cout<<y;
}
getch();
}
What is the difference between what charuzen posted and what you posted? Except that you change the variables to x and y and you prompt the user to enter the two numbers in a single line?
You still didn't correct the #include <iostream.h> and you still don't use usingnamespace std;
cout, cin and endl are part of the namespace std... If you want to use them you have to use a namespace notation: http://www.cplusplus.com/doc/tutorial/namespaces.html
1 2 3
usingnamespace std;
using std::cout;
std::cout << "out";
And clrscr() is not part of c++ STL. It works only with Borland C++.
What is the difference between what charuzen posted and what you posted? Except that you change the variables to x and y and you prompt the user to enter the two numbers in a single line?
OoOoPs! dang it!
didn't notice....
btw, #include<iostream.h> is used in old compilers,
well, i think he's using one so i thought it didnt made any problems.., plus, in that old compiler, using
1 2 3
usingnamespace std;
using std::cout;
std::cout << "out";
does not work...
anyway, just choose between getch(); and return 0;....
getch(); and return 0; are two completly different things...
getch(); Is used to catch a keystroke from the user.
return 0; Is the return of a function, or in this case the return of the main which terminates the program.
You can have them both. In this example you just use one to make your program wait for a keystrike and the other to make your program end and return to its caller the value 0.