-
Notifications
You must be signed in to change notification settings - Fork 0
C_Booleans.c
SunilOS edited this page Sep 9, 2024
·
1 revision
#include <stdio.h> // Includes the standard input/output library, needed for printf function
#include <stdbool.h> // Includes the library to use boolean data types like 'bool', 'true', and 'false'
int main() {
bool isTrue = true; // Declares a boolean variable 'isTrue' and assigns it the value 'true'
// Prints the boolean value (in C, 'true' is represented as 1 and 'false' as 0)
printf("Boolean value: %d\n", isTrue);
return 0; // Returns 0 to indicate successful execution
}-
#include <stdbool.h>: Includes thestdbool.hheader, which provides boolean types (bool,true,false). -
bool isTrue = true;: Declares a boolean variableisTrueand assigns the valuetrue(represented as1). -
printf("Boolean value: %d\n", isTrue);: Prints the boolean value. In C,trueis output as1, andfalsewould be output as0.