-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbool.cpp
68 lines (51 loc) · 1.8 KB
/
bool.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using std::cout ;
int main(){
cout << std::boolalpha << true << std::endl ; // -> true
if (true) cout << "true" ; // -> tru
bool TRUE = 1 ;
bool FALSE = 0 ;
std::cout << std::endl << std::endl ;
std::cout << std::boolalpha << TRUE << std::endl ;
std::cout << std::boolalpha << FALSE << std::endl ;
std::cout << (bool)true+(bool)100 << std::endl << std::endl << std::endl ; // -> 2
TRUE = true ;
FALSE = false ;
std::cout << "&& - AND" << "\n" ;
std::cout << "true && false" << " -> " << (TRUE && FALSE) << std::endl ;
std::cout << "true && true" << " -> " << (TRUE && TRUE) << std::endl ;
std::cout << "false && false" << " -> " << (FALSE && FALSE) << std::endl << "\n ";
TRUE = true ;
FALSE = false ;
std::cout << "|| - OR" << "\n" ;
std::cout << "true || false" << " -> " << (TRUE || FALSE) << std::endl ;
std::cout << "true || true" << " -> " << (TRUE || TRUE) << std::endl ;
std::cout << "false || false" << " -> " << (FALSE || FALSE) << std::endl << "\n ";
TRUE = true ;
FALSE = false ;
std::cout << "! - NOT" << "\n" ;
std::cout << "!true" << " -> " << !TRUE << std::endl ;
std::cout << "!false" << " -> " << !FALSE << std::endl ;
std::cout << true + true << std::endl ; // -> 2
while(1){
std::cout << "1 is true" << std::endl ;
break ;
}
while(true+true){
std::cout << "true + true" << std::endl ;
break ;
}
while (1+1){
std::cout << "1 + 1" << std::endl ;
break ;
}
while(0+0){
std::cout << "0 + 0" << std::endl ;
break ;
}
while(99999){
std::cout << "999999" << std::endl ;
break ;
}
std::cout << std::boolalpha << (bool)9999999999 << std::endl ;
}