External Publication
Visit Post

[Beginner, C] If we can represent true/false with 1/0, why do we need the stdbool library and boolean variables?

People > Companies ❤️ - programming.dev [Unofficial] March 14, 2026
Source

submitted by emotional_soup_88 to learn_programming 14 points | 17 comments

I saw one example

int x = 10;
int y = 5;

bool isGreater = x > y;

printf("%d", isGreater);

But I could write this

int x = 10;
int y = 5;

printf("%d", x > y);

I am a complete beginner and I have no real reason why I would or would not want to deal with boolean variables, but I want to understand their raison d’être.

Edit: typo city

Discussion in the ATmosphere

Loading comments...