fork(3) download
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    
    int i=0, compnum=rand()%1000, guess;
    char quit;
    
    while (quit != 'y'){
        cout << "The computer has guessed a number between 1 and 1000, try to guess the number: ";
        cin >> guess;
        
        while (guess != compnum){
        if (guess < compnum){
            cout << "\nThe amount you guessed is less than the number the computer chose, try again: ";
            cin >> guess;
        }//end if
        else if (guess > compnum){
            cout <<"\nThe amount you guessed is greater than the number the computer chose, try again: ";
            cin >> guess;
        }//End elseif
        else {
            break;
        }//end else
        }//end while 
        
        cout << "\nCongrats, you guessed the number the computer had guessed: \n\n";
        
        
        
        
     cout << "Do you want to quit y/n? ";
     cin >> quit;
    }
    

    
    
    
    return 0;
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
900
100
400
933
y
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6: error: ‘rand’ was not declared in this scope
prog.cpp:6: warning: unused variable ‘i’
stdout
Standard output is empty