Skip to content

Instantly share code, notes, and snippets.

@Flaze07
Created June 9, 2017 04:39
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 Flaze07/d3f094aafe53aa2cbd188a042f94b1fc to your computer and use it in GitHub Desktop.
Save Flaze07/d3f094aafe53aa2cbd188a042f94b1fc to your computer and use it in GitHub Desktop.
#include <iostream>
int main()
{
enum class Condition {bigger, smaller, equal};
int input1;
int input2;
Condition condition;
std::cout << "enter first number\n";
std::cin >> input1;
std::cout << "enter second number\n";
std::cin >> input2;
if (input1 > input2)
{
condition = Condition::bigger;
}
else if (input1 < input2)
{
condition = Condition::smaller;
}
else if (input1 == input2)
{
condition = Condition::equal;
}
if (condition == Condition::bigger)
{
std::cout << "first number is bigger\n";
}
else if (condition == Condition::smaller)
{
std::cout << "first number is smaller\n";
}
else if (condition == Condition::equal)
{
std::cout << "both numbers are equal\n";
}
return 0;
}
@Flaze07
Copy link
Author

Flaze07 commented Jun 9, 2017

I know this code contains overhead but this is just to teach my friend about enum...specifically enum class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment