Units

Unit: Random Number Generation - Questions and Answers

Practice these Random Number Generation under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Random Number Generation for following purpose.

– Anyone who is wishing to increase their perfect knowledge of Random Number Generation of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Random Number Generation.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Random Number Generation under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Random Number Generation topic of C Programming:

1.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        printf("%d\n", srand(9000));`
5. `        return 0;`
6. `    }`

Explanation:

2.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    #include <stdlib.h>`
3. `    int main()`
4. `    {`
5. `        printf("%d\n", rand() % 1000);`
6. `        return 0;`
7. `    }`

Explanation:

3.

In the below program everytime program is run different numbers are generated.

1. `    #include <stdio.h>`
2. `    #include <stdlib.h>`
3. `    int main()`
4. `    {`
5. `        printf("%d\n", rand());`
6. `        return 0;`
7. `    }`

Explanation:

4.

The correct way to generate numbers between minimum and maximum(inclusive) is _________________

Explanation:

5.

Which is the best way to generate numbers between 0 to 99?

Explanation:

6.

In the below program everytime program is run different numbers are generated.

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        srand(time(NULL));`
5. `        printf("%d\n", rand());`
6. `        return 0;`
7. `    }`

Explanation:

7.

Which of these is a correct way to generate numbers between 0 to 1(inclusive) randomly?

Explanation:

8.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        srand(time(NULL));`
5. `        printf("%d\n", rand());`
6. `        return 0;`
7. `    }`

Explanation:

9.

Which among the following is correct function call for rand and random?

Explanation:

10.

The function srand(unsigned)

Explanation:

11.

Which of the following snippet will effectively generate random numbers?

Explanation:

12.

What is the return type of rand() function?

Explanation:

13.

Which of the following can be used for random number generation?

Explanation:

14.

rand() and srand() functions are used

Explanation:

15.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    #include <stdlib.h>`
3. `    int main()`
4. `    {`
5. `        srand(9000);`
6. `        printf("%d\n", rand());`
7. `        return 0;`
8. `    }`