This one actually was really difficult at first but I asked fo help to ken and some classmates and at the end I made the program work well.

#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
srand((unsigned)time(0));
int i;
i = (rand()%100)+1;
int contador = 0 ;
int x = 0;{
cout << “Introducir numero del 1 al 100 incluidosn”;
cin >> x;
contador = contador + 1;
if (x > i){
cout << “El numero a encontrar es menor al tuyo.” << endl;
}
if (x < i){
cout << “El numero a encontrar es mayor al tuyo.” << endl;
}
}
while(x != i){
cout << “No le atinaste. Intento numero ” << contador << endl;
contador = contador + 1;
if (x != i) {
cout << “Introducir numero del 1 al 100 incluidosn”;
cin >> x;
if (x > i){
cout << “El numero a encontrar es menor al tuyo.” << endl;
}
if (x < i){
cout << “El numero a encontrar es mayor al tuyo.” << endl;
}
}
if (x == i) {
cout << “¡Le atinaste!” << endl;
cout << “Tuviste ” << contador << ” intentosn”;
}
}
cout <<  i << “n”;
return 0;

}

This is the program.

Tu número ..

https://www.flickr.com/photos/gua_pa/

CC BY 4.0 alan46bc 2015-09-17 23:09:42 by alan46bc is licensed under a Creative Commons Attribution 4.0 International License.