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

  • teaHead74@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    20 hours ago

    If u accidentally us the wrong type of variable it outputs en error when compiling. That’s one of the main pros of statically typed languages and why the most reliable scripts are written in them to my knollidge. I’m sure there a languages out there where u can us boolean as a int or float but non i know. Not that i would consider my self a programmer but i asked the myself the same questions when i started.