Could some one answer a few questions?

Started by
16 comments, last by Forgotten 21 years ago
The book probably does have examples, if not, feel free to experement with this simple program:


    #include <iostream>#include <cstdlib>using namespace std;/* This returns a random number between min and max. Don't worry   too much how it does what it does for now. */int RandomNumber(int min, int max) {  return rand()%(max-min+1)+min; }int main() {  // This seeds the random number generator with the current  // time so that we will get different numbers every time  // we run it.  srand(time(0));    // Prints the programs title.  cout << "The random number guessing game!" << endl       << "The answer is between 1 and 100!" << endl;      // This variable stores the correct answer.  int answer = RandomNumber(1, 100);    // This variable stores the users guess.  int users_guess;    do // Do everything in the curly brackets while users     // guess doesn't equal the answer   {    // Print message asking user for guess.    cout << "What is your guess? ";        // Get the users response.    cin >> users_guess;        // If guess is bigger than answer, tell user it was too high.    if(users_guess > answer)     cout << "Nope, too high." << endl;        // If guess is smaller than answer, tell user it was too low.     if(users_guess < answer)     cout << "Nope, too low." << endl;   }  while(users_guess != answer);    // The user has guessed the answer, let them know.  cout << "You win! Good job." << endl;    // If you're using Dev-C++ this line will keep the  // program from quitting before the user can see what we  // wrote.  system("pause"); }    


[edited by - smart_idiot on March 26, 2003 12:45:42 PM]
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Advertisement
ok, Thank you.
you''ve helped alot
I agree that if you havent programmed before in another language, it may be hard to understand the concepts of C++. Im understading how things work because ive done it with VB and Java.

You should seriously think about doing a language like Java. Its a nice beginning object oriented langauge that should get you somewhat prepared for what C++ is like.

I wish you good luck in your programming future.
The Mind!!
Thank you for the luck... the thing is about learning a diff language is i want to make a game SO bad that id jump of the cliff oppesed to walking the paved path.
question 1, do you have a compiler available? is it setup? do you know how to compile and run a program?

if any of the above are no, then you should probably take a day out of learning to code, and just concentrate on getting a compiler setup, and building a ultra simple program, asking for help if you need it.
You might want to try a better book if you can afford it, and this one is very good for beginners new to programming: Dietel & Dietel Learn To Program


Moo moo MOO moo moo

[edited by - Bovine Supremacy NOW on March 27, 2003 5:31:38 PM]
Moo moo MOO moo moo
I agree with BSN, I found many of the Dietel & Dietel programming books (I have the c, c++, and Java books) helpful and have used them to find good helpful exercises for tutoring others in my college classes.

Thanks,CodeJunkie
First of all, programming , although difficult, can be accomplished with time and practice. I'm a beginner myself, but I've had my share of troubles trying to learn things, but I just kept trying and eventually accomplished my goal. I'm a new programmer and my first language is C++(although I am learning C at the same time) and I havn't found it to be too difficult. I have the C++ dummies book, and if you want my opinion, I really don't like it. The thing about the book, is that it gives code that I do not feel is accurately explained. Particularly the section on arrays. Anyway, I highly recommend a C++ book that gives you excercises to complete based on the knowledge given to you in the book. You don't truly learn how to master anything until you've used the knowledge you've learned to accomplish something on your own. Don't be discouraged, just keep trying and looking for other ways to learn the same information, visit websites, other books etc. A good website that gives the very basic information is www.cprogramming.com. I recommend it for learning the basics of C++ but you should consult other sources as well because it leaves out some information.

[edited by - bioagentX on March 28, 2003 12:09:35 PM]

[edited by - bioagentX on March 28, 2003 12:11:08 PM]
There are three types of people in this world, those who can count, and those who can't

This topic is closed to new replies.

Advertisement