Log In Register

Units


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.     }

Answer: Option D

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.     }

Answer: Option B

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.     }

Answer: Option C

Explanation:

4.

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

Answer: Option C

Explanation:

5.

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

Answer: Option C

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.     }

Answer: Option D

Explanation:

7.

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

Answer: Option B

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.     }

Answer: Option C

Explanation:

9.

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

Answer: Option D

Explanation:

10.

The function srand(unsigned)

Answer: Option C

Explanation:

11.

Which of the following snippet will effectively generate random numbers?

Answer: Option C

Explanation:

12.

What is the return type of rand() function?

Answer: Option C

Explanation:

13.

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

Answer: Option D

Explanation:

14.

rand() and srand() functions are used

Answer: Option A

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.     }

Answer: Option C

Explanation: