Conversion of boolean values to numbers

Asked

Viewed 53 times

2

How do I get the answer from False be it 0 and True be it 1

equal in C?

That is, I wish the answer of: u=(1>2)

be it 0 and not False?

Thank you

  • 1

    What do you mean by answer ? Write on console ? Why the tag c ? He’s trying to write 0 when it is False and 1 when it is True ?

1 answer

4

Just cast the cast to int

u=(1>2)
print(int(u))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.