C++ Console Lesson 22: Using the rand() Function

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
17,888
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Mar 4, 2009

More at http://xoax.net
This C++ video tutorial shows how to use the rand() function to generate random numbers in C++.

Please submit all questions to our forum:
http://xoax.net/forum/

  • likes, 1 dislikes

Link to this comment:

Share to:

Top Comments

  • very nice as usual :)

  • Very useful lesson. The music in the background I find to be quite off putting though. I learnt something new though!

see all

All Comments (15)

Sign In or Sign Up now to post a comment!
  • hey I got the same numbers he got when I ran this program :)

  • @twilightevans Not necessarily. Since you are using the same compiler as xoax (I'm assuming you are, anyway), the compiler has defined the limit as 32767.

  • can you also make a rand() function that the function chooses between four values?

    for example, if i want the program to choose randomly whether the operator is "+", "-", "*" or "/"?

  • to do rand() for a minimum other than 1 or 0, do this : rand()%(max-min) + min, for example : rand()%(25-10) + 10, this will generate a random number from 10 -25

  • @Martyfan666 - Why is it when we won't put up with something, it's off-putting. Shouldn't it be down-putting? That's just my input.

  • @ripsnorting13

    set 2 variables that the user enters and then have a rand with those 2 variables

    .............................

  • How do i generate numbers in a user defined set of numbers. Im making a game that allows a person to enter in a lowest number and highest number and then program will make you guess the number. Please help if can!

  • I can easily copy this code and use it on my own and get things to work... But why are timers used? I don't get it o.O

  • @AaronGomori make sure that you are using Empty Project under application settings when creating the project

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more