# C Programming Questions and Answers – Random Number Generation – 1

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Random Number Generation – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

1. What is function srand(unsigned)?
a) Sets the seed for rand
b) Doesn’t exist
c) Is an error
d) None of the mentioned

Explanation: None.

2. Which is the best way to generate numbers between 0 to 99?
a) rand()-100
b) rand()%100
c) rand(100)
d) srand(100)

Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

3. Which is the correct way to generate numbers between minimum and maximum(inclusive)?
a) minimum + (rand() % (maximum – minimum));
b) minimum + (rand() % (maximum – minimum + 1));
c) minimum * (rand() % (maximum – minimum))
d) minimum – (rand() % (maximum + minimum));

Explanation: None.

4. rand() and srand() functions are used _____________
a) To find sqrt
b) For and operations
c) For or operations
d) To generate random numbers

Explanation: None.
Check this: C Books | BCA MCQs

5. What is the return type of rand() function?
a) short
b) int
c) long
d) double

Explanation: None.

6. Which of the following can be used for random number generation?
a) random()
b) rnd()
c) rndm()
d) none of the mentioned

Explanation: None.

7. Which of the following snippet will effectively generate random numbers?
a) rand();
b) rand(10);
c) rand(time(NULL));
d) all of the mentioned

Explanation: None.

8. Which among the following is correct function call for rand() and random()?
a) rand() and random();
b) rand() and random(1);
c) rand(1) and random(1);
d) rand(1) and random();

Explanation: None.

9. For the function call time(), what type of parameter is accepted?
a) int
b) int *
c) time_t
d) time_t *

Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers. 