Generate a random number between 100 and 200 Print it to the

Generate a random number between 100 and 200. Print it to the output screen.

Solution

Please follow the code and comments for description :

CODE :

#include <iostream> // required header files
#include <ctime> // Needed for the true randomization
#include <cstdlib>

using namespace std;

int main () // driver method
{
   int randNum; // variable initialisation
   srand(time(NULL)); // ensuring a randomized number by help of time
  
   randNum = 100 + (rand() % (200 - 100)); // Randomizing the number between 100-200
   cout << \"Random number between 100 - 200 : \" << randNum << endl; // print to screen
  
   return 0;
}

OUTPUT :

For various runs of the code, the generated results are :

Random number between 1-15 : 190

Random number between 1-15 : 154

Random number between 1-15 : 101

Random number between 1-15 : 139

Random number between 1-15 : 169

Hope this is helpful.

 Generate a random number between 100 and 200. Print it to the output screen.SolutionPlease follow the code and comments for description : CODE : #include <i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site