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
View Answer
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)
View Answer
Explanation: None.
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));
View Answer
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
View Answer
Explanation: None.
5. What is the return type of rand() function?
a) short
b) int
c) long
d) double
View Answer
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
View Answer
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
View Answer
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();
View Answer
Explanation: None.
9. For the function call time(), what type of parameter is accepted?
a) int
b) int *
c) time_t
d) time_t *
View Answer
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Apply for Computer Science Internship
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Practice BCA MCQs
- Check C Books