Guessing game. Write a c++ game that asks the user to guess a number between 1 and a 100. If you guessed correctly, it will say you win. If your too high or too low it will also let you know.

Can you show us the code you have so far?

in a loop :

    step 1 input a number after a prompt was printed

    step 2 check if number was in valid range 1..100
           if not 
           after printing error message
           continue back from loop top

    step 3 get computer to produce a random value in range 1..100

    step 4 ...

I suggest you to use the rand() function to generate a pseudo-random number.

#include <cstdlib>

int target = rand() % 100 + 1; 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.