Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Last active December 23, 2015 21:19
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 natemcmaster/6695194 to your computer and use it in GitHub Desktop.
Save natemcmaster/6695194 to your computer and use it in GitHub Desktop.
Tutoring: sample of various ways to use bool in C++
#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