Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@marklocklear
Created March 31, 2022 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklocklear/47111890c1cc4c98385f13f81e09f2bf to your computer and use it in GitHub Desktop.
Save marklocklear/47111890c1cc4c98385f13f81e09f2bf to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main() {
string light;
cout << "What is the traffic light color?" <<endl;
cin >> light;
if(light == "green"){
cout << "Go!" <<endl;
}
else if(light == "yellow"){
cout << "Slow down!" <<endl;
}
else if(light == "red"){
cout << "Stop!" << endl;
}
else{
cout << "invalid entry" << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment