Random Numbers

The program below prints 3 random numbers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//Random numbers
#include<iostream>
using namespace std;
int main() {
  int num;
  num = rand(); //generates a random number
  cout << num << endl;
  num = rand(); //generates a random number
  cout << num << endl;
  num = rand(); //generates a random number
  cout << num << endl;
  system("pause");
  return 0;
}//main
CODE
Output:
41
18467
6334
Press any key to continue . . .

Unfortunately, it will display the same 3 numbers each time you run it.

NEXT: Set the seed