Home » C++ Programming » Numbers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <ctime>
    #include <cstdlib>
    using namespace std;
    int main()
    {
    srand((unsigned)time(0));
    int ran;
    int L = 11, H = 100;
    int R = (H - L) + 1;
    for(int k = 0; k < 1; k++)
    {
    ran = L + int(R * rand() / (RAND_MAX + 1.0));
    cout << ran << endl;
    }
    }
    1. 100
    2. 11
    3. 1.0
    4. Compilation Error
    5. None of these
Correct Option: B

In this program, We have generated a certain random number by using the above formula.



Your comments will be displayed only after manual approval.