Hi there people. This task was a little different, because you had to use another library, and some different functions.

  • The library <ctime> or <time.h> which is the same, is used here to measure time, so you can generate a new random number every time you run the program.
  • The variables I use are x: for the random number; y: for the number you enter; and i: for the counter.
  • In the line 16 of my code I’m using the symbols <  ||  >, which is the logical function OR.
    if (y<=0 || y>100) {
    cout<<endl;
    cout<<Remember that the number should be between 1 and 100…<<endl;
    }

So what the code stated for the if, will run when one OR another condition is TRUE.

  • Everything else in the code is easy and you should’ve used it for some previous WSQ’s.

https://github.com/EduardoMacielM/TC1017/blob/master/random.cpp

CC BY 4.0 #WSQ06 Pick a Number by eduardomacielm is licensed under a Creative Commons Attribution 4.0 International License.