Last active
October 2, 2019 19:50
-
-
Save andermoran/9a314c5cabaa4665b169fe7fa69e63b0 to your computer and use it in GitHub Desktop.
Ways to evaluate boolean expressions in c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
bool b = true; | |
// High school level | |
if (true) { | |
cout << "simple conditional" << endl; | |
} | |
// Freshman in college level | |
if (b == true) { | |
cout << "intermediate conditional" << endl; | |
} | |
// PhD level | |
if (strncmp ((b ? "true" : "false"),"true",5) == 0) { | |
cout << "advanced conditional" << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment