-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean.cpp
More file actions
36 lines (30 loc) · 748 Bytes
/
boolean.cpp
File metadata and controls
36 lines (30 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
int main(){
bool red_light{false};
bool green_light{true};
if(red_light==true){
cout<<"Stop"<<endl;
}
else{
cout<<"Go through"<<endl;
}
if(green_light){
cout<<"the light is green"<<endl;
}
else{
cout<<"the light is not green"<<endl;
}
// sizeof()
cout<<"sizeof(bool) : " <<sizeof(bool)<<endl;
//printing out a bool
//1-->true
//2-->false
cout<<endl;
cout<<"red_light : "<<red_light<<endl;
cout<<"green_light : "<<green_light<<endl;
cout<<boolalpha;
cout<<"red_light : "<<red_light<<endl;
cout<<"green_light : "<<green_light<<endl;
return 0;
}