What to do:

Write a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen, you choose which one works best for you.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

The program continues to run until the user guesses the integer. You could do something extra here including telling there user how many guesses they had to make to get the right answer.

You might want to check that your program doesn’t always use the same random number is chosen and you should also split your problem solving into parts. Perhaps only generate the random number and print that as a first step.


First we looked for the way to create the random number, we found a good post that helped us a lot. Then we started reading a little more about counters and the while function that was the one that made me more suitable for my program. After a bit of analysis finally came out the program but I have a fault in the counter that I did not know how to remove it, I hope Ken can explain to me.


Sources of research:


#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
int num,resp,intentos;
do {
std::cout << “ya estoy listo para jugar” << ‘\n’;
std::cout << “¿cual numero crees que tengo para ti?” << ‘\n’;
std::cin >> resp;
if (num<resp) {
std::cout << “lo siento, pero tu numero es muy alto” << ‘\n’;
if (num>resp) {
std::cout << “lo siento, pero tu numero es muy bajo” << ‘\n’;
} while(num!=resp);
std::cout << “lo lograste!!!, el numero mágico es:” <<num<< ‘\n’;
std::cout << “lo obtuviste en: ” <<intentos<<“intentos”<< ‘\n’;
return 0;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s