How to print boolean in c Code Answer's

The Boolean data type is used to store a logical condition, where TRUE or FALSE represents the result of an expression or statement. You can use Boolean variables as flags to indicate whether a condition is true or not. When you have a boolean variable, it can be easily printed in the console by using the %b format specifier.

how to print boolean in c

By Adventurous AddaxAdventurous Addax on Dec 14, 2020
printf("%s", x ? "true" : "false");

Source: stackoverflow.com

Add Comment

2

print bool c

on Jan 01, 1970
// there is no way of pretty-print a boolean with printf
printf("%i", true);  // will print 1
printf("%i", false); // will print 0

// but we can create a macro
#define formatBool(b) ((b) ? "true" : "false")
printf("%s", formatBool(true));  // will print true
printf("%s", formatBool(false)); // will print false

Add Comment

0

The Above Code example shows how to print boolean in C programming language.

C answers related to "how to print boolean in c"

View All C queries

C queries related to "how to print boolean in c"

Browse Other Code Languages

CodeProZone