#include <iostream>
using namespace std;
int main(void) {
int number, guess;
srand(time(NULL));
number = rand() % 101;
cout << "Guess a number between 0-100: ";
cin >> guess;
if(number > guess) {
cout << "The number is greater!\n";
}
else if(number < guess) {
cout << "The number is smaller!\n";
}
else {
cout << "Cognratulations! The number is "number"!\n";
}
cin-get();
return 0;
}
error: 'srand' was not declared in this scope
error: 'rand' was not declared in this scope
error :expected ';' before 'number'
You need to add:
#include <cstdlib>
to include srand() and rand()
When you need to use functions like this, looking at the man pages (or googling them) will tell you which header(s) you need to include.
http://www.cplusplus.com/reference/clibrary/cstdlib/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With