// Notice the spelling here
char choie;
cout << "Do you like"" green eggs and ham?"""
<< "Enter 'y' or 'Y' for"" yes, 'n' or 'N' for no: ";
// And the spelling here.
cin >> choice;
As for std::cin not defined it is because you don't have a using statement for it. You have the using declarations for cout and endl but not cin. So you will either need to use std::cin or add using std::cin;
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main() {
char choice; // for the user's input
// prompt for the user's choice
// - in this small block specifically, some things are unnecessary (and
// therefore not the best coding practice). but do they cause compiler
// errors? :)
cout << "Do you like"" green eggs and ham?"""
<< "Enter 'y' or 'Y' for"" yes, 'n' or 'N' for no: ";
cin >> choice;
cout << endl;
// respond to the user's choice!
if (choice == 'y' || choice == 'Y')
cout << "Me too!\n";
elseif (choice == 'n' || choice == 'N')
cout << "Me neither?\n";
else {
cout << "I don't understand :(\n";
cout << endl;
// analyze the user's choice
switch (choice) {
case'y':
case'n': cout << "You entered a lower case letter.\n"; break;
case'Y':
case'N': cout << "You entered an upper case letter.\n"; break;
default: cout << "You entered an invalid letter!\n"; break;
}
cout << endl;
// print the letters from 'A' or 'a' to the user's choice, or exit if the
// user's choice was invalid
char start; // the character to begin printing from
if (choice == 'Y' || choice == 'N') {
start = 'A';
}
elseif (choice == 'y' || choice == 'n') {
start = 'a';
}
else {
cout << "I am unhappy. Terminating.\n";
return 1; // error
}
cout << "The letters from '" << start << "' to '" << choice << "' are:\n";
for (char c = start; c <= choice; c++)
cout << c << " ";
cout << endl;
return 0; // success
}