How to Generate Random Numbers in C language using rand srand and time function

Поділитися
Вставка
  • Опубліковано 4 лис 2024

КОМЕНТАРІ • 172

  • @Jose-oy1ow
    @Jose-oy1ow 4 роки тому +40

    I have a programming assignment focused on these functions due in a few days and you just taught me everything i need to know about random number generation for the assignment.
    Thank you so much!

    • @LearningLad
      @LearningLad  4 роки тому +3

      Best of luck!

    • @rahulmadhukar2617
      @rahulmadhukar2617 Рік тому +1

      Now, I also have the same type of assignment...

    • @Ihatesnakeuu007
      @Ihatesnakeuu007 11 місяців тому

      Wait I have same type of assignment too that's why I am here

  • @princevegeta9980
    @princevegeta9980 3 роки тому +35

    Me having any study related problems
    An Indian Guy on UA-cam: "Who's summoned me now?"
    Thanks mate!

  • @juswantht2271
    @juswantht2271 2 роки тому +5

    WoW...You explained from scratch..
    Got a crystal clear idea.
    Thank you sir..

  • @GOWTHAMR-di8dl
    @GOWTHAMR-di8dl 10 місяців тому +2

    Thank you for such a awesome video

  • @gauridewangan2192
    @gauridewangan2192 3 місяці тому +2

    Thankyou so much for your efforts to explain it in much easier way... Great job!

  • @felix7954
    @felix7954 3 роки тому +7

    thank you very much, your explanations are very good and I finally understand how this function works!

  • @pokemonprince06
    @pokemonprince06 2 місяці тому +1

    this is what we call full explanation .😍

  • @米酒儲
    @米酒儲 2 роки тому +2

    the way you explained the concept was super clear.
    Thank you so much!!!!!!!!!

  • @MadihaMuskan-py1xf
    @MadihaMuskan-py1xf 3 місяці тому +2

    Just amazing bro thanks

  • @Starflamea
    @Starflamea Рік тому +2

    this is so enlightening. you're a good teacher

  • @sodiqabdulramon
    @sodiqabdulramon Рік тому +1

    Finally, you made me understand that tricky little thing!!!!

  • @UncontrolleDperson
    @UncontrolleDperson Рік тому +2

    And now you can ask: "Why do i need rand function?". Many simulations and
    scientific studies need to repeat the same set of random numbers. rand() will always
    do that if you don’t seed the random number generator.

  • @UncontrolleDperson
    @UncontrolleDperson Рік тому +1

    Thanks!!! I think i almost get it! I should watch the video one more time))))

  • @erkein1092
    @erkein1092 3 роки тому +3

    best way of explaining, thanks dude

  • @maryammuhamad6215
    @maryammuhamad6215 3 роки тому +2

    Thank you really i followed all the your steps and it will be installed 🙏🏻❤️

  • @vnr699
    @vnr699 3 роки тому +2

    Thank you very much it's straight to the point and very useful !!!

  • @hayatasuenaga7028
    @hayatasuenaga7028 3 роки тому +1

    You're better than my professor...

  • @sharataggarwal3858
    @sharataggarwal3858 3 роки тому +2

    A very clean and simple explanation for the topic. I have been struggling with this for some time now. But so glad to have found the video.

  • @TheStriked
    @TheStriked Рік тому +1

    brilliant explanation, thank you so much

  • @pichanakaduku8391
    @pichanakaduku8391 4 роки тому +2

    your c++ and c courses are superb bro

  • @yesitsme6
    @yesitsme6 2 роки тому +8

    Great explanation sir, thank you a lot
    Btw congratulations for 100 comments, you truly deserve a lott

  • @DipakKumar-ey9ix
    @DipakKumar-ey9ix 3 роки тому +1

    awesome expalanation , thank u mr. anil shetty !!!

  • @zladsmusic8953
    @zladsmusic8953 3 роки тому +7

    YOU SAVED ME THANK YOU SO MUCH

  • @shubrochakroborty5918
    @shubrochakroborty5918 3 роки тому +1

    Bro you are going to hit the sky high followers soon.
    Amazing video

  • @cuongday9005
    @cuongday9005 Рік тому +1

    yout just helped me so much, thanks all

  • @Devi1_rideR.s
    @Devi1_rideR.s 2 роки тому +3

    Can you help me to create a random array using rand (seed) of 10,00,000 size for linear search to find time complexity, Sir.
    Pls help me to create the array using rand of that size.

  • @atmajap6339
    @atmajap6339 3 роки тому +1

    This was the best explanation. Thank you so much sir.

  • @Camila-do8ot
    @Camila-do8ot Рік тому +1

    Excellent, thank you very much!

  • @lukeauslender6494
    @lukeauslender6494 Рік тому +1

    Solid lesson. Thanks 🙏🏼

  • @sleepypanda7172
    @sleepypanda7172 3 роки тому +3

    damn You are the most amazing man on this planet! you explain effortlessly! Big big thanks

  • @mvelisompukuzela9034
    @mvelisompukuzela9034 2 роки тому +1

    This was really helpful, clear explanation

  • @imsonecka
    @imsonecka 11 місяців тому +1

    thank you so much!! this was really useful.

  • @khetanshusingh9059
    @khetanshusingh9059 8 місяців тому +1

    Great explanation
    Thanks a lot

  • @irwanahmed001
    @irwanahmed001 2 роки тому

    Thank you for your clear and concise explanation!!

  • @ishmam8643
    @ishmam8643 4 роки тому +1

    Your explanation was really good.
    Thanks to you I understood how the fucking function works.

  • @kevinshao1099
    @kevinshao1099 2 роки тому +1

    thanks for helping me study final

  • @eventidewatcher
    @eventidewatcher 3 роки тому

    Could you share what you use to do screen recording and providing that yellow highlight? I have to record a video for my C class. Excellent explanation on the topic :)

    • @wesley_makes
      @wesley_makes 3 роки тому

      I've used screen capture in OBS Studio for both Mac and Windows. Whether the cursor is highlighted or not is a setting in OBS. For Windows, I've also used VSDC, but after learning OBS, I don't think I'm going back.

  • @ANUSHKASRIVASTAVA-yy3wp
    @ANUSHKASRIVASTAVA-yy3wp 3 роки тому +2

    Thank you so much sir...very well explained :)

  • @naokikayama750
    @naokikayama750 3 роки тому +1

    too many ads but it helped me understand !

    • @LearningLad
      @LearningLad  3 роки тому

      I don’t think I have inserted many ads
      Nowadays youtube plays 2 ads continuously
      I will check it
      Glad that my video helped you

  • @vedran2277
    @vedran2277 Рік тому +1

    very good explanation!

  • @k-5773
    @k-5773 2 роки тому

    The sequence of random numbers generated will be different on each run after using srand but is it possible to get a same number which was generated in previous run of the program as in a duplicate?

  • @iSubhoo
    @iSubhoo 3 роки тому +1

    Greatly explained, thank you.

  • @berg.worldNow
    @berg.worldNow 2 роки тому +1

    CONGRATULATIONS ON THE VIDEO

  • @JohnDoe-kj2cs
    @JohnDoe-kj2cs 3 роки тому +1

    I like video and I have hit the like button

  • @thesaltck5736
    @thesaltck5736 2 роки тому

    how to find the given dataset random number use, what type of algorithm is used?

  • @shinimasud8931
    @shinimasud8931 9 місяців тому

    Well explained thank you very much :D

  • @prince_adn
    @prince_adn 3 роки тому +1

    Thanks a lot , you're the best bro

  • @umutaydn6184
    @umutaydn6184 Рік тому +1

    thanks for the explanation

  • @epabitra
    @epabitra 3 роки тому

    Very much helpfull video sir

  • @rbdarshana3856
    @rbdarshana3856 2 роки тому +1

    Please teach random number generation by using Norma distribution

  • @aleksandarlukic736
    @aleksandarlukic736 4 роки тому +1

    Very cool video! Can't wait for the next part with range as parameter :D

  • @g-ster
    @g-ster 3 роки тому +1

    awesome logic man

  • @mickysinghania5584
    @mickysinghania5584 4 роки тому +1

    beautifully explained...

  • @nisharai5952
    @nisharai5952 2 роки тому

    Thank you for this video💕It was really helpful!

  • @neerajshetty1144
    @neerajshetty1144 2 роки тому

    Great explanation

  • @cabasiravenallyzal.5522
    @cabasiravenallyzal.5522 2 роки тому

    Hi. I'll just ask, where can I find the random number generator compiler?

  • @thediychannel2805
    @thediychannel2805 4 роки тому +1

    Good
    It was really helpful

  • @wasitthat
    @wasitthat 3 роки тому

    Cant you use a pointer to address to seed? Each compile should be different no?

  • @Ap-ui6kk
    @Ap-ui6kk 2 роки тому +1

    I want to create an array with different numbers 0 to 9 but I dont want same numbers in array. (for ex I dont want {0,2,3,6,2,0,1,4,3}) Can u guys help me please ?

    • @yesitsme6
      @yesitsme6 2 роки тому +2

      I think its not possible, what is possible is to take input from user

    • @Ap-ui6kk
      @Ap-ui6kk 2 роки тому +1

      @@yesitsme6 I have solved it. Thank you :)

    • @yesitsme6
      @yesitsme6 2 роки тому +1

      @@Ap-ui6kk Can u send me the code of how u do that? My tests comming

  • @mdsikdarsaiful1610
    @mdsikdarsaiful1610 2 роки тому

    can you explain about your channel logo?

  • @dilanlakshitha2737
    @dilanlakshitha2737 3 роки тому +1

    great teacher

  • @Vutsman1
    @Vutsman1 3 роки тому

    What if you need a random number from 1 to 1 million, with a seed 179. The first iteration is 545994 but I can't get it.
    I'd like to know how to do this.

  • @flixtreammedia3440
    @flixtreammedia3440 4 роки тому +1

    can we save the random number in a variable so we create a varification process in which user verify the random number

    • @LearningLad
      @LearningLad  4 роки тому

      yes you can do that :)

    • @flixtreammedia3440
      @flixtreammedia3440 4 роки тому

      @@LearningLad I tried but [if()] function is not working when int userinput == rand()

  • @ArjunCS
    @ArjunCS 3 роки тому

    give this man an oscar

  • @brainbonkers12
    @brainbonkers12 3 роки тому

    can you tell how to generate random position for shapes in c I am really struggling with that thing

  • @_misheel_
    @_misheel_ 3 роки тому

    help me a lot really appreciate

  • @gurunathrathod2973
    @gurunathrathod2973 4 роки тому +1

    Super well and good Sir

  • @ladientyo1055
    @ladientyo1055 3 роки тому

    How would you reset the count so that if I was to loop this function 5 times the random numbers don’t add up

  • @hanfihadje2148
    @hanfihadje2148 Рік тому +1

    Thank you so much

  • @gamustoff
    @gamustoff 3 роки тому

    Please how can i start by number negative .exp : -7 ----> 10

  • @wg8798
    @wg8798 4 роки тому +2

    Thanku so much sir

  • @desmondyeboah127
    @desmondyeboah127 Місяць тому +1

    you are good

  • @epabitra
    @epabitra 3 роки тому

    Sir the srand ask for which number the max number or the start number

    • @epabitra
      @epabitra 3 роки тому

      If it ask for start number then how the rand() returns the number which less then srand value.

  • @mohammedalez5145
    @mohammedalez5145 Рік тому +1

    thanks alot 🥰

  • @JoaoVictor-iw9co
    @JoaoVictor-iw9co Рік тому +1

    Thank you

  • @Snow-df3jh
    @Snow-df3jh 3 роки тому

    I want these function to execute only once each time it is called how to do that?

  • @mohansaikrishnamopada6646
    @mohansaikrishnamopada6646 3 роки тому +1

    Awesome 😍😍

  • @_abdalla2910
    @_abdalla2910 Рік тому +1

    Thanks bro

  • @kira_x55
    @kira_x55 5 місяців тому

    Thanks guy

  • @tusharsaxena9778
    @tusharsaxena9778 3 роки тому

    I've used seed and rand function in loop to generating random numbers but i got the same value from 1 loop.

  • @2_-
    @2_- 2 роки тому

    //for c++
    const short minValue = 1; //set to any number you want
    const short maxValue = 6; //set to any number you want
    srand(time(0));
    int randomNumber = (rand() % (minValue - maxValue)) + 1;
    cout

  • @leykohos
    @leykohos 11 місяців тому +1

    Thanks!!!!!

  • @arulananthams2540
    @arulananthams2540 Рік тому +1

    Awesome

  • @RAMANKUMARGCEBIT
    @RAMANKUMARGCEBIT 2 роки тому

    very helpful

  • @gelfetogebre8301
    @gelfetogebre8301 2 роки тому

    why does mine and your computer prints the same random number?

  • @hiluu
    @hiluu 2 роки тому +1

    thanks

  • @shadenabdulaziz3388
    @shadenabdulaziz3388 3 роки тому

    Thx Legend!!

  • @lukasjetu9776
    @lukasjetu9776 2 роки тому

    nice

  • @SaniaParvin-v7o
    @SaniaParvin-v7o 18 днів тому

    How to generate random alphabet

  • @Mr_NoobPlay
    @Mr_NoobPlay Рік тому +1

    🔥🔥🔥🔥🔥🔥❤

  • @elite4782
    @elite4782 2 роки тому

    why null you say??

    • @Farhan-hf7ls
      @Farhan-hf7ls Місяць тому

      I think null puts the time in seconds from 1-1-1970 if u had to use some parameter then I wouldn't be random(the same problem)

  • @sykesdoktor8272
    @sykesdoktor8272 2 роки тому

    indian guy carry

  • @MayankGoel447
    @MayankGoel447 2 роки тому +1

    Thanks for this helpful video! In my program RAND_MAX generated is 2147483647. Doe random_max depend on compiler since now int in most compilers is of 4 bytes?

  • @TheVaivoda
    @TheVaivoda 2 роки тому +1

    Great explanation. Thank you

  • @aleeza5000
    @aleeza5000 4 роки тому +2

    Thank you so much, this was very helpful!

  • @abedammar7407
    @abedammar7407 3 роки тому +1

    thank you

  • @abd1428
    @abd1428 3 роки тому +1

    thanks bro

  • @rohitpandit5961
    @rohitpandit5961 9 місяців тому

    thanks brother