Numbers


  1. What is the output of this program?
     #include <iostream>
    #include <cstdlib>
    using namespace std;
    int main()
    {
    cout << RAND_MAX << endl;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    RAND_MAX is a function used by the compiler to create a maximum random number.


  1. What is the output of this program?
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    int main()
    {
    int Ran = rand();
    cout << Ran << endl;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    As the declared number is integer, It will produce the random number from 0​ to RAND_MAX. The value of RAND_MAX is library-dependent, but is guaranteed to be at least 32767 on any standard library implementation.



  1. How many parameters are available in srand function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    There is one parameter available in srand function. That is an integer value to be used as seed by the pseudo-random number generator algorithm.


  1. Which is a constant defined in <cstdlib> header file?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    RAND_MAX is a constant defined in <cstdlib> for deciding the maximum random number that can be produced.



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    cstdlib header file is used to create pseudo random number. C++11 standard added random header file as well to generate random numbers.