//"Adivine el numero"
//Instrucciones: do-while - if-else
//Anderson Ponciano
//03/06/2020
#include <iostream>
#include <cstdlib>
#include <ctime>
//Se define el valor maximo aleatorio
#define MAX_RANGE 100
using namespace std;
main ()
{
    int contador=0;
    long valor, n_adivinar;
    system ("color FC");
    srand (time (NULL) );   //Initializar la funcion random
    valor = rand()%MAX_RANGE+1; //entre 1.. MAX_RANGE
    cout <<"\nEscriba un valor entre 1 y "<< MAX_RANGE << " : ";
    do {
        cin >>n_adivinar;       //Almacena el valor
        contador++;             //Incrementa el contador
        if (valor>n_adivinar)   //Es mayor, valida el valor ingresado
        cout << "el numero es menor que " <<n_adivinar <<". Pruebe otra vez: ";
        else {
            cout << "Es el numero correcto " <<n_adivinar<<"\n";
        }
    } while (valor!=n_adivinar);
    return system("pause");
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: