fork(3) download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main(){
  5.  
  6. int i=0, compnum=rand()%1000, guess;
  7. char quit;
  8.  
  9. while (quit != 'y'){
  10. cout << "The computer has guessed a number between 1 and 1000, try to guess the number: ";
  11. cin >> guess;
  12.  
  13. while (guess != compnum){
  14. if (guess < compnum){
  15. cout << "\nThe amount you guessed is less than the number the computer chose, try again: ";
  16. cin >> guess;
  17. }//end if
  18. else if (guess > compnum){
  19. cout <<"\nThe amount you guessed is greater than the number the computer chose, try again: ";
  20. cin >> guess;
  21. }//End elseif
  22. else {
  23. break;
  24. }//end else
  25. }//end while
  26.  
  27. cout << "\nCongrats, you guessed the number the computer had guessed: \n\n";
  28.  
  29.  
  30.  
  31.  
  32. cout << "Do you want to quit y/n? ";
  33. cin >> quit;
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40. return 0;
  41. }
  42.  
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