UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why do we use srand ((time (NULL))?

Asked by Last Modified  

Follow 1
Answer

Please enter your answer

You need to under the concept and definition of function and you must visualize how does it work.Before going to srand, try to see subset of it, its rand1. rand -- provide random number generator (as its int, so range falls under 0 - 327672. srand - its "seed"random number - that means used to set the...
read more

You need to under the concept and definition of function and you must visualize how does it work.
Before going to srand, try to see subset of it, its rand
1. rand -- provide random number generator (as its int, so range falls under 0 - 32767
2. srand - its "seed"random number - that means used to set the starting value (seed), for generating. So, its set seed(1) as default and on top of it rand() generates random number between seed and range <32 ,767>
3. Time - is every changing at every second, just think if you are sending current time vallue as seed -> to srand (which initializes) -> inturn -> rand() get calls. Now, the range of random generation number is less.
4. So instead of some static integer , as end user we want to supply, make use of the computer's internal clock to controlthe choice of the seed.

Hope it helps.

 

read less
Comments

Related Questions

Can you define which header file to include at compile time?
Yes we can do it by using conditional comilation
Thileshwari
0 0
5
In C/C++, when should you use the comma (,) operator instead of the semicolon (;) statement terminator?
int a=2; b=a; b=a+2; Instead of the above two statements we can write it as b=(a,a+2); The value of b is 4
Thimma
0 0
5
Why do we use # in C programming?
In the C programming language, # is used for preprocessor directives. The preprocessor is a program that runs before the compiler and processes special directives that begin with # . These directives allow...
Dhanya
0 0
5
How can I develop my C language?
Developing your proficiency in the C programming language involves a combination of learning, practice, and real-world application. Here are some steps to help you enhance your skills in C: Learn the...
Himanshu
0 0
5
Why is C still so popular?
C remains popular for several reasons, and its enduring popularity can be attributed to a combination of historical significance, efficiency, and versatility. Here are some key reasons why C is still widely...
A
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Array vs Linked List
Array Linked List Accessing element is easy. Accessing element is difficult compare to Array. Easy to use. Difficult to use. Memory is Fixed size. Memory is variable size. If...

Why C is a Language and not a database?
When I interviewed a candidate, I raised this question many times, but I have not got the answer correctly. To under why C is a language and not a database, it is good to understand why our communication...

Set 0 To Kth Bit In A Variable
The following code snippet Set 0 to Kth Bit in an variable #include int UnsetBitValue(int n, int k);int main(){ printf("%d\n\n",UnsetBitValue(255,6)); return 0;}// Set kth bit to zeroint UnsetBitValue(int...

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

Operators in C
Operators in C Operator: An operator is a symbol that tells the compiler to perform certain mathematical or logical calculations. Operators are used in programs to manipulate data and variables. The...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more