Guess the number

This WSQ was about making a program that picks a random number between 1 and 100 and then give you clues for you to know if you are near of the random number or not. Also the user is able to know how many guesses did he had to make to get the correct answer.

Even I had an idea of how to do this program, I needed to search how to generate a random number. Here are some links that I used for making this task: Tool 1, Tool 2, Tool 3. Also a video, it was not the same thing but it was really similar.

After searching I noticed that I had to use some other libraries: stdlib.h and time.h . The first one was needed so I could be able to use ” rand() ” for generating the random number, and the second one was a library to know the actual hour of the system, this because if not it would always generate the same number. So if we use that library it would not be possible to generate a same number twice because its not possible to use the program twice or more in a second.

randomatom.jpg

I need to make this program twice because for any reason the first one that I made was not working (Yes, I compared them and they said the same but one was working and the other one not 🙁 ).

I had already use Do – While before on C# also If – else. So the main problem on this task was generating a random number and the fact that I was using new libraries.

You can see my program on github: Random number.
I attach a picture of my program working (You can notice that

randomcygwin.jpg

was making small changes just to compare to the first one that I made).

randomcygwin.jpg

CC BY-SA 4.0 Guess the number by martikaglez is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.