Easy Programming – Beginner C++ Tutorial – Random Number Generator (11)

June 28, 2020

This is another new thing that you’ll learn in C++ today. Today I show you how to create a program that acts as a random number generator and gives you a random number based on what the user inputs as the maximum value for the random number. So whether the number is 5 or 5,000,000, the program will be able to give you a random value. This is great practice for beginners with C++ and this tutorial should help further your knowledge about the basics of C++.

For help with the looping, please check out my other video located here:

In that video, I explain exactly how the “for” loop works. It’s very simple and it’s just a few minutes.

Learn how to do this in JavaScript:

And remember to visit my site to view my other programming tutorials! They are all on the website and it will be updated as soon as new programs are uploaded.

I hope you enjoy the video and if you have any requests feel free to let me know. Thanks for watching and remember to subscribe!

#EasyProgramming #C++

Visit my website:
Subscribe on YouTube:
Support me on Patreon:
Follow me on Twitter:
Like me on Facebook:
Check out my Github:

Nguồn: https://mensagensdamanha.com/

Xem thêm bài viết khác: https://mensagensdamanha.com/cong-nghe/

All Comments

  • This old tutorial really helped me 😀

    FoxTheBest June 28, 2020 11:40 pm Reply
  • I dont understand your language

    DubleThr33 June 28, 2020 11:40 pm Reply
  • ty bro

    tHARUNDA DEWMIN June 28, 2020 11:40 pm Reply
  • What about decimal numbers?

    Exotic Saber June 28, 2020 11:40 pm Reply

    Daniel Gregorio June 28, 2020 11:40 pm Reply
  • I keep getting duplicate values when I run the program. I am trying to use a random function for a lottery generator. My professor wants me to use a random function. I seeded the function, but still getting duplicate values. Any suggestions??

    Phillip Harris June 28, 2020 11:40 pm Reply
  • How to add random numbers that does not require a 50 variable but like 2 to 4 variables that repeat to equal to the total amount with two separate totals such as players to see who wins? Also, please tell how to reset values to 0 when they are too high?

    abman136 June 28, 2020 11:40 pm Reply
  • you can use #include<bits/stdc++.h> instead of most c++ libraries

    Sunil Kumar Agrawal June 28, 2020 11:40 pm Reply
  • Thank you so much!

    sineth sankalpa June 28, 2020 11:40 pm Reply
  • hey, can you help me?

    Josue June 28, 2020 11:40 pm Reply
  • i put it in a for loop that runs 4 times and the 4 numbers it gives are always the same

    Kimonellos apoel June 28, 2020 11:40 pm Reply
  • Is this completely random? Like uniformly distributed random?

    Paivren June 28, 2020 11:40 pm Reply
  • I hate C++ so much.

    Getting a random number is other languages is really easy to do, and it took me weeks just to find this tutorial that gave me a legit random number instead of a random number that is actually always the same every time.

    Pixii Bomb June 28, 2020 11:40 pm Reply
  • Outdated

    Wilhiem Bokholdt June 28, 2020 11:40 pm Reply
  • sir i need this program plzz do it and sent me thank u
    The Game of Catching Numbers
    Childers are more attracted towards computer games rather than studying mathematics. So to teach children’s of primary school, our motive is to design a game such that during their enjoyment they also learn counting numbers
    The following is the working example:
    Suppose below picture is your computer screen. The minimum following requirements must be met by your application program for Children. Extra feature will be appreciated. All the said requirements are compulsory.
     First number (object) is start with zero at the corner of the screen having screen coordinates (0, 0).  For the second number generate random number from 1 to 100 and also random coordinates.  Ten points are generated randomly as false number. If you touch those number, you will lose.(You can use array of point objects)  Now Children use the arrows key to move first number left, up, down right to reach 2nd number.  When first number reach the co-ordinates of 2nd number. Add both numbers. The resultant value now become the first number and again generate 2nd number as in step 2.  The Game will end when children complete adding 500 points.  For each addition provide a time on with which you can add numbers. If time expires and you did not reach the co-ordinates then you lose. You cannot go back that co-ordinate from where you just came.
    Use the concepts of class Point we discuss in the last two lectures, objects, for the fulfilment of this assignment.

    Total Score:
    Time Left:

    Your .h should contain these functionality to fulfil above Requirements

    This is only for your guide you may change the functions, add or remove functions according to your understanding . Class Point { Private: Double x; Double y; Int Value;

    Public: Point()//Default constructor Point(Double,Double,int)//Three Argument constructors;

    Void Shift(Point P)// Shift the first point when user press keys

    Void Initialize(Double, Double, int)

    Void generateRandomCordinates();

    Void SetValue(int Value);

    Int GetValue() Const;

    Void Setx();

    Double getX()Const

    Void Sety();

    Double gety()Const

    Void AddPointValue(Point P2);//This function add the TWO points value when your first point successfully reach on second true point co-ordinates

    Void DisplayPoint();// This will use to display value of a point on screen

    Bool CheckCorrdinates(Point p);

    Bool CheckTime();//check time remaining


    New Trends June 28, 2020 11:40 pm Reply
  • What about for random strings?

    MrRangerx88 June 28, 2020 11:40 pm Reply
  • Okay.. this is no way generates a "random" number. After trying it last night, it clearly does not generate "random" numbers over successive iterations.

    Terry Sloope June 28, 2020 11:40 pm Reply
  • can you show us how giving two dimensional array random numbers without repeating form 0 to 15

    Abdelrhman Magdey June 28, 2020 11:40 pm Reply
  • Thanks for the help!

    Jadyn Brown June 28, 2020 11:40 pm Reply
  • One of the most helpful c++ videos I've watched man thank you! Keep makin vids

    Toby Gomez June 28, 2020 11:40 pm Reply
  • Can someone please tell me how to generate a random number between a and b(user defines a and b)

    Ariton June 28, 2020 11:40 pm Reply
  • thanks man you explained it very well and specially hats off to to the algo (rand() % max )+1 works as charm once again thanks for sharing such an easy algo

    Malik Huzaifa June 28, 2020 11:40 pm Reply
  • Helped a lot, thanks!

    Noel O'Kane June 28, 2020 11:40 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *