Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to implement the Number Guessing Game. In this game, the use

ID: 3913539 • Letter: W

Question

Write a C++ program to implement the Number Guessing Game. In this game, the user chooses a number between 1 and 100, and the player tries to guess the number in as few attempts as possible. A. Each time the player enters a guess, the computer tells him whether the guess is too high, too low, or right. Once the player guesses the number, the game is over. The game should print the number of attempts the player needed to guess the number. The game should ask the player if he would like to play again. write a C++ program to figure out whether the entered number is a prime number or not. In this program, the user chooses a number between 1 and 1000, and the progranm should tell you if it is a prime number or not. B. The Program should ask the user if he would like to test another number again. Note:

Explanation / Answer

Ques 1. run this code in c++ .

#include <iostream>

using namespace std;
void Game();
int main()
{
int k=0;
Game();
cout<<"want to play again?, if yes then press 1 , if no then press 0 ";
cin>>k;
while(k==1)
{
Game();
cout<<"want to play again?, if yes then press 1 , if no then press 0 ";
cin>>k;
}
return 0;
}

void Game()
{
cout<<"Welcome to the Number Guessing Game";
int x,y;
int n=0;
cout<<" Enter one number for the game to be started, Please enter the number between 1 and 100 ";
cin>>x;
while(x<1 or x>100)
{
cout<<" Please Enter correct number";
cin>>x;
}
cout<<" Now guess the number";
cin>>y;
while(y!=x)
{
n=n+1;
if(y>x)
cout<<"too high ";
if(y<x)
cout<<"too low ";
cin>>y;
}
cout<<" Right";
n=n+1;
cout<<" You pass the game in "<<n<<" turn ";
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote