Explore topic-wise MCQs in C Programming.

This section includes 16 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.

The rand command is provided by the __________

A. Parallel Computing Toolbox
B. Signal Processing Toolbox
C. Symbolic Math Toolbox
D. Does not exist
Answer» B. Signal Processing Toolbox
2.

What is the default return type of the rand command?

A. Single
B. Double
C. Signed
D. Unsigned
Answer» C. Signed
3.

The range of numbers returned by the following code is:

A. [1,9]
B. (1,9)
C. [1,9)
D. (1,9] View Answer
Answer» B. (1,9)
4.

What is the error in the following command?

A. Error due to Inf
B. Syntactical error
C. Misspelled command
D. No errorView Answer
Answer» C. Misspelled command
5.

The linspace command generates pseudorandom numbers.

A. True
B. False
Answer» C.
6.

What is the class of the variable r after the following code is run?

A. Array
B. Single
C. Double
D. IntegerView Answer
Answer» B. Single
7.

The output of the following code

A. Error
B. A random set of numbers from the normalized normal distribution
C. A random set of numbers from the range 3,4
D. A random set of numbers from the normal distribution ranging from 3 to 4View Answer
Answer» B. A random set of numbers from the normalized normal distribution
8.

The randn command generates random numbers by following a _________

A. Normal distribution
B. Normalized Normal Distribution
C. Uniform Distribution
D. Bernoulli’s Distribution
Answer» C. Uniform Distribution
9.

For the function call time(), what type of parameter is accepted?

A. int
B. int *
C. time_t
D. time_t *
Answer» B. int *
10.

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);
11.

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);
12.

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

A. random()
B. rnd()
C. rndm()
D. none of the mentioned
Answer» C. rndm()
13.

What is the return type of rand() function?

A. short
B. int
C. long
D. double
Answer» E.
14.

rand() and srand() functions are used _____________

A. To find sqrt
B. For and operations
C. For or operations
D. To generate random numbers
Answer» C. For or operations
15.

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));
Answer» C. minimum * (rand() % (maximum ‚Äö√Ñ√∂‚àö√ë‚àö¬® minimum))
16.

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» B. rand()%100