Quantcast
Channel: OR and less than operators not working as intended C language - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Vasilis Samaras for OR and less than operators not working as...

if (v || u <= 0) considers v as a boolean variable so it is true for every non zero value. So your if is true for any non zero v. Use if (v <= 0 || u <= 0)

View Article



Answer by Govind Parmar for OR and less than operators not working as...

if (v || u <= 0) is not saying "if v is less than or equal to zero OR if u is less than or equal to zero", like I believe you think it is. It's actually saying "if v is not zero, OR u is less than...

View Article

OR and less than operators not working as intended C language

I'm doing an exercise of a book called programming in C language, trying to solve exercise 7.9 and so my code works perfectly until I add a conditional statement for the function to only accept...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images