If C doesn’t have Boolean values, what is the alternative in situations that would normally require one? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

If C doesn’t have Boolean values, what is the alternative in situations that would normally require one?

15th Oct 2018, 3:43 PM
Drew Pesall
Drew Pesall - avatar
6 Answers
+ 15
Standard C (since C99) provides a boolean type, called _Bool . By including the header stdbool.h , one can use the more intuitive name bool and the constants true and false . ... Objective-C also has a separate Boolean data type BOOL , with possible values being YES or NO , equivalents of true and false respectively. Initial implementations of the language C(1972) provided no Boolean type, and to this day Boolean values are commonly represented by integers ( int s) in C programs. The comparison operators ( > , == , etc.) are defined to return a signed integer ( int ) result, either 0 (for false) or 1 (for true).
15th Oct 2018, 3:51 PM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
+ 7
On one project, I've worked it was: #define TRUE 1 #define FALSE 0
16th Oct 2018, 7:14 AM
shaldem
shaldem - avatar
+ 5
bool works! as said by Abhi Varshini https://code.sololearn.com/cS7jNLt09tRk/?ref=app Isn't it bool? I mean cool 😂
17th Oct 2018, 5:24 AM
Infinity
Infinity - avatar
+ 2
Though C doesn’t support Boolean value. But we can use Logical Operators like ‘&&’, ‘||’ or ‘!’. We can do several logical program with these. If any one need some Fuzzy Logic boolean values, it can be modified by define preprocessors shaldem mention before..
16th Oct 2018, 6:17 PM
Bits!
- 1
Use 0 and 1
2nd May 2019, 6:30 PM
Werg Serium
Werg Serium - avatar
- 1
0 is false and 1 is true
2nd May 2019, 6:31 PM
Werg Serium
Werg Serium - avatar