-
What is the output of this program?
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(0));
int num;
for (int k = 0; k < 2; k++)
{
num = (rand() % 10) + 1;
cout << num;
}
}
-
- 2
- 20
- 10
- Any two number from 1 to 20
- Compilation Error
Correct Option: D
In this program, It will produce two numbers from 1 to 20 by using srand function.