Help im a noob

This is a discussion on Help im a noob within the C++ Programming forums, part of the General Programming Boards category; okay so lets say Code: int lol = 40; int i = lol + rand()%40; k so now we know ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    3

    Help im a noob

    okay so lets say


    Code:
    int lol =  40;
    
    int i = lol + rand()%40;
    k so now we know i its going to be 40(lol) + a random number between 0 and 40

    but how could i accomplish that i could be any number between 0 and 40 o.o? help please.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by macmiller View Post
    k so now we know i its going to be 40(lol) + a random number between 0 and 40

    but how could i accomplish that i could be any number between 0 and 40 o.o? help please.
    Seriously ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    3
    Quote Originally Posted by manasij7479 View Post
    Seriously ?
    lols, you dont get it i mean when you do rand ........ then its just 1 number between the 0 and 40 but i want it to be all numbers between 0 and 40

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by macmiller View Post
    lols, you dont get it i mean when you do rand ........ then its just 1 number between the 0 and 40 but i want it to be all numbers between 0 and 40
    If you want all numbers between 0 and 40, why use rand ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  5. #5
    Registered User
    Join Date
    May 2012
    Posts
    3
    Quote Originally Posted by manasij7479 View Post
    If you want all numbers between 0 and 40, why use rand ?
    it was just to set a have something to compare with, anyway do you happen to know the correct code?

  6. #6
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    You haven't yet written clearly what your program is supposed to do.
    Until you do that, you'll not get a definite answer, only guesses.

    If you just need to list all the numbers from 1 to 40, use a loop.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A noob need help
    By ticktoc09 in forum C Programming
    Replies: 5
    Last Post: 02-26-2011, 01:37 AM
  2. Noob Help......If/Else :S
    By matt.s in forum C Programming
    Replies: 8
    Last Post: 03-20-2010, 03:37 PM
  3. The noob(me) needs help again! plz...
    By shadowsora15 in forum C++ Programming
    Replies: 11
    Last Post: 06-01-2007, 04:56 PM
  4. Need help...I'm a noob
    By viciousv322 in forum C++ Programming
    Replies: 8
    Last Post: 05-24-2007, 11:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21