Last active
December 23, 2015 21:19
-
-
Save natemcmaster/6695194 to your computer and use it in GitHub Desktop.
Tutoring: sample of various ways to use bool 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> | |
using namespace std; | |
bool foobar(int f){ | |
return (f==7); | |
} | |
int main(){ | |
bool foobarcondition=foobar(7); | |
if(foobarcondition){ | |
cout<<"Foobar equals 7"<<endl; // this is printed | |
} | |
bool condition = false; | |
if(condition){ | |
cout<<"Condition is true"; // this is NOT printed | |
} | |
int i=5; | |
bool expression = (i == 5); | |
if(expression){ | |
cout<<"The expression is true"<<endl; //this is printed | |
} | |
else{ | |
cout<<"the expression is false"<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment