Taking that and compiling it gives me the simple error:
fatal error: iostream.h: No such file or directory
This is self-explanatory. The reason is that <iostream>
doesn’t have an extension, or a .h
equivalent. Change the line to:
#include <iostream>
Proof that it compiles (not including the following points, but removing things irrelevant to ideone): http://ideone.com/WIDjR
Aside from that:
-
You don’t need
windows.h
.system
is part ofcstdlib
. -
using namespace std;
often does more bad than good. It’s recommended to stick tostd::cout
etc. Insidemain
isn’t the worst place it could be, but nonetheless, not a great habit to get into. -
if( number >= 2 && number <= 2 )
is a logic error, both in writing and execution. The simpler form would beif (number == 2)
, but the correct form, based on your output, would beif (number != 2)
, lest every number other than 2 is the right guess. -
system ("PAUSE")
is bad. You don’t know ifpause.exe
will do that, or if it will even exist. Someone could have apause.exe
that formats their hard drive, and you’d be to blame for executing it. Use a form ofcin.get()
, or, if your compiler implements it to clear the input buffer,cin.sync(); cin.get();
for consistent behaviour. Beware thatcin.sync()
‘s behaviour is not guaranteed. -
Your program should be returning 0 from normal exit. Anything else is taken to mean an error occurred.
return 0;
in main is implicit if you don’t specify a return value.