CPP

CPP

Random Numbers has 9 Questions

Which header file is used to create the pseudo random generator?

random
cstdlib
rand
None of the mentioned
Which is a constant defined in header file?

RAND_MAX
rand
srand
None of the mentioned
How many parameters are available in srand function?

1
2
3
4
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main()
  5.     {
  6.         int ran = rand();
  7.         cout << ran << endl;
  8.     }

Any number
89
0"? to RAND_MAX
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     int main ()
  5.     {
  6.         srand (time(NULL));
  7.         printf ("Random number: %d\n", rand() % 100);
  8.         srand (1);
  9.         return 0;
  10.     }

12
23
33
Any number from 0 to 100
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main()
  6.     {
  7.         srand((unsigned)time(0));
  8.         int ran;
  9.         for (int i = 0; i < 2; i++)
  10.         {
  11.             ran = (rand() % 10) + 1;
  12.             cout << ran;
  13.         }
  14.     }

2 4
10 20
Any two number from 1 to 10
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main()
  6.     {
  7.         srand((unsigned)time(0));
  8.         int ran;
  9.         int low = 1, high = 10;
  10.         int range = (high - low) + 1;
  11.         for(int index = 0; index < 1; index++)
  12.         {
  13.             ran = low + int(range * rand() / (RAND_MAX + 1.0));
  14.             cout << ran << endl;
  15.         }
  16.     }

1
2
3
4
Which operator is used to produce a certain number in a specific range?

$
%
modulo operator
None of the mentioned
Which can be can be used to create a random number without duplication?

Character
Time
Both a & b
None of the mentioned