código que realice un juego
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; int main() { srand(time(NULL)); int random_number = rand() % 100; int guess; int attempts = 0; cout << "Guess the number:" << endl; do { cin >> guess; if(guess > random_number) cout << "Too big" << endl; else if(guess < random_number) cout << "Too small" << endl; attempts++; } while (guess != random_number); cout << "You guessed the number in " << attempts << " attempts" << endl; return 0; }