MCQOPTIONS
Saved Bookmarks
This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
For the function call time(), what type of parameter is accepted? |
| A. | int |
| B. | int * |
| C. | time_t |
| D. | time_t * |
| Answer» E. | |
| 2. |
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(); |
| Answer» B. rand() and random(1); | |
| 3. |
Which of the following snippet will effectively generate random numbers? |
| A. | rand(); |
| B. | rand(10); |
| C. | rand(time(NULL)); |
| D. | all of the mentioned |
| Answer» B. rand(10); | |
| 4. |
Which of the following can be used for random number generation? |
| A. | random() |
| B. | rnd() |
| C. | rndm() |
| D. | none of the mentioned |
| Answer» B. rnd() | |
| 5. |
What is the return type of rand() function? |
| A. | short |
| B. | int |
| C. | long |
| D. | double |
| Answer» C. long | |
| 6. |
rand() and srand() functions are used _____________ |
| A. | To find sqrt |
| B. | For and operations |
| C. | For or operations |
| D. | To generate random numbers |
| Answer» E. | |
| 7. |
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)); |
| E. | ?a) minimum + (rand() % (maximum – minimum));b) minimum + (rand() % (maximum – minimum + 1));c) minimum * (rand() % (maximum – minimum))d) minimum – (rand() % (maximum + minimum)); |
| Answer» C. minimum * (rand() % (maximum – minimum)) | |
| 8. |
Which is the best way to generate numbers between 0 to 99? |
| A. | rand()-100 |
| B. | rand()%100 |
| C. | rand(100) |
| D. | srand(100) |
| Answer» C. rand(100) | |
| 9. |
What is function srand(unsigned)? |
| A. | Sets the seed for rand |
| B. | Doesn’t exist |
| C. | Is an error |
| D. | ?a) Sets the seed for randb) Doesn’t existc) Is an errord) None of the mentioned |
| Answer» B. Doesn’t exist | |