I get what your saying I haven't changed it yet because I originally had x as 8 and some other stuff thats why it still like that.
I get what your saying I haven't changed it yet because I originally had x as 8 and some other stuff thats why it still like that.
My computer is awesome.
>>It's the wording that's wrong.
Oops. I just saw if(guess > x) and "guess" and "high"
>>becuase it doesn't generate a random number yet.
Sure it does. Well, you've forgot to seed the random-number generator by calling srand() at the top of main(), but what do you mean it doesn't generate a random number?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
[Warning] initilization from 'int' to 'double'Code:int x = (((double)rand() / (double) (RAND_MAX + 1)) * (10 - 1 +1)) + 1;
[Warning] argument from 'int' to 'double'
syntax error before do
Could you post a lil code or explain to me how to call srand plz?
My computer is awesome.
How about you just go read the FAQ, like you've already been told?
Quzah.
Hope is the first step on the road to disappointment.
And, it's been posted at least twice on the first page of this thread.
>> syntax error before do
Yes, like I pointed out, you're missing a ';' after int guess.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
thanks, I already said I don't understand the FAQ.
My computer is awesome.
Read the
FAQ
Woop?
Was there not a whole bunch of discussion about this just recently?
My computer is awesome.
How you cannot read basic material and understand it?
Yes it was discused but we still don't understand why you can't just read and comprehend simple material.
Woop?
Jeez. Read some posts before you talk.Originally Posted by Hunter2TwoMinutesAgo
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
Alright, so before I skimmed it and it looked complicated.
This time I read it and believe I've made some progress.
I know I haven't fixed everything else yet, but I added srand and the answer is 8 everytime I compile it.Code:#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(int argc, char *argv[]) { srand ( (unsigned int) time (0)); int x = (((double)rand() / (double) (RAND_MAX + 1)) * (10 - 1 +1)) + 1; int guess; do { cout << "im thinking of a number between 1 and 10\n"; cout << "enter your guess please\n"; cin >> guess; if (guess == x) { cout << "you are correct\n"; } else if (guess < x) { cout << "guess a higher number\n"; } else if (guess > x) { cout << "your not supposed to guess this high\n"; } else { cout << "guess a lower number\n"; } }while (guess != x); system("pause"); return 0; }
My computer is awesome.
Its in plain sight guy your logic for rand is way off.
Originally Posted by FAQ
Woop?
I changed your code so it works i hope this gives you a general idea of how to generate a "random" number next time
Code:#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(int argc, char *argv[]) { srand ( (unsigned int) time (0)); int x = rand()%5; int guess; do { cout << "im thinking of a number between 1 and 10\n"; cout << "enter your guess please\n"; cin >> guess; if (guess == x) { cout << "you are correct\n"; } else if (guess < x) { cout << "guess a higher number\n"; } else if (guess > x) { cout << "your not supposed to guess this high\n"; } else { cout << "guess a lower number\n"; } }while (guess != x); system("pause"); return 0; }
cgod you never cease to amaze me.....
Woop?
Whats so bad about my answer? its not really good code but it helps him get started so he can understand better ways of doing it at lest it gets his program working.