Thread: Random integer (1-10)

  1. #1
    Registered User Zenomori's Avatar
    Join Date
    Apr 2005
    Hinesville, GA

    Random integer (1-10)

    I was wondering how to use the Rand feature ( i think that is what it is called) to make an integer randomize from 1 to 10. ( im a beginner at this)

    P.S If Someone could point me in the direction of a good starter book that would be awesome!

  2. #2
    Registered User
    Join Date
    Aug 2004
    San Diego, CA
    rand()%10 + 1

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    seed your random number generator:
    srand(time(NULL));   // do this once per run of the program

    then you can do this:
    Originally posted by Lithorien
    rand()%10 + 1

    vvv And here are some books vvv
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    And read the FAQ. (Or the tutorial?)
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Registered User osolis's Avatar
    Join Date
    Apr 2005
    A C++ book i think is awesome is "C++ Programming: from problem analysis to program design" i borrowed the book from someone who is taking a CSCI class the book is pretty expensive though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. Array help
    By Oklaskull in forum C Programming
    Replies: 19
    Last Post: 03-11-2008, 04:15 PM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. problem with random integer
    By techno logic in forum C++ Programming
    Replies: 1
    Last Post: 10-07-2002, 02:20 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM