Building a Guessing Game | C++ | Tutorial 21

preview_player
Показать описание

Throughout the course we'll be looking at various topics including variables, arrays, getting user input, loops, conditionals, object orientation, and much more.
Рекомендации по теме
Комментарии
Автор

I love how straightforward you are and your voice is really soothing!

sanan.chaudhry
Автор

3:00
its
int secretNum =7;
int guess;
do {
cout<<"enter guess ";
cin>>guess;
} while (secretNum != guess);
cout<<"you win";

ShogMain
Автор

👍Thumbs up for this video. I've learned about using loops for making a guessing game..

inovinoclaudine
Автор

hello mike this code runs on code blocks perfectly but then gives an error on vs the guess variable need be initialized before the loop

briann.
Автор

Excuse me I'm working to add an array in our game. I mean the we have to guess multiple numbers. I used array but failed. Sir can you help me in solving my problem.

ur_frequency
Автор

Can i ask sir Dane? If i guess the number on first trial and i write a wrong number on the last trial, why the output tells wrong if i got already the number

edwinnavarro
Автор

It works as long as I enter pure numbers, but as soon I enter few letters cin getting ignored and while loop goes infinite. How to sanitize input and ignore letters?

alexandrtcacenco
Автор

My pycharm isn't working well, do you recommend any other programming language for absolute beginners?

fessenic
Автор

We didn't use endl in the code for guess game. Why then enter a guess statement is always in a new line when we enter a wrong guess?

nidhisethi
Автор

Sir can u help me with my assignment?please

avneetrandhawa
Автор

Instead of a number if I have to enter a word or letter what do I do??

that
Автор

if you guess a letter the program goes ape shit, 10/10

theactualljazzman
Автор

#include <iostream>
#include<string>


using namespace std;


int main()
{

int guess;
const int secretnum=7;
int countguesses=0;
const int limit=3;
bool outofguess=false;

do
{
if(countguesses<limit)
{
cout<<"Enter the guess: ";
cin>>guess;
countguesses++;
}
else
{
outofguess=true;
}
}


if(!outofguess)
{

cout<< "You Win!";
}
else
{
cout<<"You Lose!";
}
return 0;
}

abdulrhmanmagdy