programming-examples/c++/11_Numerical_Problems/C++ Program to Use rand and srand Functions.cpp
2019-11-15 12:59:38 +01:00

20 lines
405 B
C++

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main(int argc, char **argv)
{
cout << "First number: " << rand() % 100;
srand(time(NULL));
cout << "\nRandom number: " << rand() % 100;
srand(1);
cout << "\nAgain the first number: " << rand() % 100;
return 0;
}
/*
First number: 41
Random number: 98
Again the first number: 41