I am trying to write this code which asks "Write a program that
ask the user, the question: What is a^b?
//The program generates two signed integers and gives the user four
attempts to get the correct answer
//a=- , b = +
//a= + , b = - "
So far this what I wrote. I am not sure how to do this correctly.
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
int guess,a,ans,b, k;
char response = 'y';
while (response != 'n')
{
unsigned int ans = pow(a, b);
a = 1 + rand() % 10;
b = 1 + rand() % 10;
cout << "What is a^b"
<< endl;
for (int i = 1; i <= 4;
i++)
{
k = i;
cin >>
guess;
if (guess ==
ans)
break;
if (guess !=
ans)
cout << "Your answer is incorrect"
<< endl;
if (guess !=
ans)
cout << "Your answer is incorrect"
<< endl;
if (guess !=
ans)
cout << "Your answer is incorrect"
<< endl;
}
if (k == 4 && guess !=
ans)
{
cout <<
"Four attempts allowed, play again? (y or n)" << endl;
cin >>
response;
}
else
{
cout <<
"Your guess is right, play agan (y or n)" << endl;
cin >>
response;
}
}
system("pause");
return 0;
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
I am trying to write this code which asks "Write a program that ask the user,...
I am trying to run this program in Visual Studio 2017. I keep getting this build error: error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". 1>Done building project "ConsoleApplication2.vcxproj" -- FAILED. #include <iostream> #include<cstdlib> #include<fstream> #include<string> using namespace std; void showChoices() { cout << "\nMAIN MENU" << endl; cout << "1: Addition...
please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then write each user guess and answer to the file. (on separate lines) Write the number of guesses to the file at the end of the game. After the game is finished, ask the user if they want to play again. If 'n' or 'N' don't play again, otherwise play again! NOTE: your file should have more than one game in it if the user...
Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis With each guess... If the guess does not have an equal number of characters, tell the user...
In this project, you will write a complete program that allows the user to play a game of Mastermind against the computer. A Mastermind game has the following steps: 1. The codebreaker is prompted to enter two integers: the code length n, and the range of digits m. 2. The codemaker selects a code: a random sequence of n digits, each of which is in the range [0,m-1]. 3. The codebreaker is prompted to enter a guess, an n-digit sequence....
Hello, I am working on a C++ pick 5 lottery game that gives you the option to play over and over. I have everything working right except that every time the game runs it generates the same winning numbers. I know this is an srand or rand problem, (at least I think it is), but I can't figure out what my mistake is. I've tried moving srand out of the loop, but I'm still getting the same random numbers every...
Please do a flowchart which will be on the computer not on paper so i can read it and be able to take screenshot for this c++ code this code for MasterMind //System Libraries #include <iostream> //Input/Output Library #include <cstdlib> #include <ctime> using namespace std; //User Libraries //Global Constants, no Global Variables are allowed //Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc... //Function Prototypes //main int main(int argc, char** argv) { //Set the random number seed srand(time(0)); int randomint = (rand()%5)+1;...
i have two issues that i need help. 1- that in case three and two only one line is being read from the file 2- my case 4 is not working correctly as it should as the output is only " Enter 1 for Trump, 2 for Warren:" #include <iostream> #include <cctype> // For the letter checking functions #include <fstream> // For file input #include <iomanip> // For setw #include <ctime> #include <cstdlib> // For exit and abs #include <errno.h>...
I need help with coding with c++. I need to make a lottery program where you enter in 5 numbers from 0-9 and the program will generate 5 random numbers 0-9 to represent the lottery numbers. I'm almost done, but the output isn't exactly what I want. It works fine, but the format should look like this: lottery array: 7 4 9 1 3 user array: 4 2 9 7 p.s. I also need to count how many matching numbers...
I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...
Write a c++ code into the given code to find composite numbers from the given random number list. The composite numbers is only counted once if there is a repeated number. I need to use this code and add on a code to find if the numbers generated is a composite function. Please help #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; int main() { srand(time(NULL)); int size_of_list = 0; // the number of random...