Hey guys having some trouble with an assignment I have due.
The criteria my prof gave is this :
You are asked to write a program for the users to guess a secret character (between lower case letter ‘a’ and
‘z’) stored inside the program. The user is allowed to have a maximum of 3 guesses. Read the following
scenario to understand the program requirements. (Hint: All letters are represented as numbers (e.g.
Unicode) inside the memory. So, when you are comparing letters, you are actually comparing their code in
numbers. Thus, letter ‘a’ is smaller than ‘b’. That is, ‘a’ < ‘b’ < ‘c’……………………….<’x’<’y’<’z’.
Also more criteria is I must use a loop, and go global variables are allowed.
I don't understand what he means by the letter a is smaller than b and so forth. If I could get some help with that it would be greatly appreciated.
This is the code I have so far, it shows the general idea in which I was going in but it gives me an error when I put the 2nd while.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
string cinput='\0';
char chrSecretLetter = 'g';
cout<< "Please enter a letter between a and z: ";
cin>> cinput;
while (cinput = "a", "b", "c","d","e","f")
{cout<<"Incorrect! Please enter a letter smaller than"<<cinput<<"."<<endl;
}
while (cinput == chrSecretLetter)
{
}
|