I don't have much experience programming in C++ so I was using the quiz part of this site to practice a bit. One of the quizzes was to complete a Guessing Game program. I did but I'm having a very hard time compiling it. I'm sure it's a simple thing but hopefully, someone here can point me to my errors. Below is my code and below that, I'll show how I'm compiling and the results I get.
Thanks in advance.
Code:#include <stdlib.h> #inlcude <iostream> using namespace std; int main() { int number=rand()%10+1; int guess = -1; int trycount = 0; while(guess != number && trycount < 8) { cout<<"Please enter a guess: "; cin>>guess; if(guess < number) cout << "Too low" <<endl; if(guess > number) cout<<"Too high" <<endl; trycount++; } if(guess == number) cout << "BINGO!!! You guessed the number!"; else cout << "Sorry, the number was: " << number; return 0; }g++ guessingGame.cpp -o guessingGameguessingGame.cpp:2:2: error: invalid preprocessing directive #inlcude
guessingGame.cpp: In function ‘int main()’:
guessingGame.cpp:14: error: ‘cout’ was not declared in this scope
guessingGame.cpp:15: error: ‘cin’ was not declared in this scope
guessingGame.cpp:18: error: ‘endl’ was not declared in this scope
guessingGame.cpp:21: error: ‘endl’ was not declared in this scope
guessingGame.cpp:28: error: ‘cout’ was not declared in this scope
guessingGame.cpp:31: error: ‘cout’ was not declared in this scope



LinkBack URL
About LinkBacks


