Guess!

The Fork CC licensed photo by Stefano on Flickr
The Fork CC licensed photo by Stefano on Flickr

This WSQ is about a program that picks a number from 1 to 100 and then asks the user to guess the number. The program must give clues like “Too high or too low”. At the end the program prints how many times you tried.

Here is my code:

06 Guess

I had to do some research on google and ask a friend; it took me around an hour to figure out how to set a random number. I manage to make it work but honestly I don’t understand every part of the code. There are many coding blogs in which you can look for basic structures and use of some commands.

I copied and pasted this “srand” function and at the end it worked. Another cool function that saved me a lot of time is the “FOR” loop. It works with three parameters and you can save plenty of space using this function. Again, in order to learn how to use “for” I recommend just searching on google and even better, ask someone who already know programming. It might sound ovbious, even dumb, but for me it has been the best option (even better than asking Ken… just kidding Ken, love your class). I recommend to ask people of third semester because they coursed this subject one year ago and they still remember pretty well about C++, may be if you try with someone of 7th semester he or she probably won’t remember.

CC BY 4.0 WSQ06 by Octavio Rojas is licensed under a Creative Commons Attribution 4.0 International License.