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

preview_player
Показать описание
In this tutorial you will learn how to generate Random numbers using rand() srand() and time() functions in C Programming language.

In c language rand function is used for getting random numbers. To make sure that we get different sequence of random numbers for separate runs, we use srand function and pass the system time in seconds using time function.

To use rand and srand functions, we need to include stdlib header file and for getting time using time function we need to include time.h header file.

C Program to generate Random Numbers between a Range of Values

For more tutorials visit our website

LearningLad in social media
Рекомендации по теме
Комментарии
Автор

Finally someone who explains it thoroughly, like talking to a 5-year-old kid. Great job!

wdiwpxm
Автор

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

princevegeta
Автор

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!

Jose-oyow
Автор

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

aleksandarlukic
Автор

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

gauridewangan
Автор

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

juswantht
Автор

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

felix
Автор

Thank you for your clear and concise explanation!!

irwanahmed
Автор

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

ljplqxm
Автор

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

vnr
Автор

Thank you for this video💕It was really helpful!

nisharai
Автор

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

yesitsme
Автор

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

maryammuhamad
Автор

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.

Devi_rideR.s
Автор

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?

k-
Автор

Thank you so much, this was very helpful!

aleeza
Автор

this is so enlightening. you're a good teacher

Starflamea
Автор

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.

sharataggarwal
Автор

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

sleepypanda
Автор

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

ladientyo