Answers for "how to make a guessing game in c++"

C++
0

how to make a guessing game in c++

#include <iostream>
#include<cmath>
// not perfect tho
using namespace std;

int guessgame(int guessnum){
    int numberguess =0;
    int limit = 5;
 switch(guessnum){
  case 9:
      cout<< "you win";
      break;
  default:

    while(guessnum != 9&& numberguess < limit){

        cout << "too bad please try again: ";
        cin >> guessnum;
        numberguess++;
        }
}
 if (numberguess <= limit&& numberguess > 0){
 cout<< "you still win anyway ";}
 else if(numberguess = limit && numberguess >0){ cout << "you lose";}
}
Posted by: Guest on September-17-2021

Code answers related to "how to make a guessing game in c++"

Browse Popular Code Answers by Language