How to bind conditions within c language if

Asked 2 years ago, Updated 2 years ago, 48 views

if((num1 != 0 && num2 != 0 && num1 == num2) || (num1 != 0 && num2 != 0 && num1 == num2)) {
Photo examples
}

Can you tie the conditions in the if in the form of the picture above?

I tried it that way, but the inside of the if didn't work. If there's a solution, I'd like you to tell me!

c if문

2022-09-21 16:09

2 Answers

if(num1 != 0)

can be coded as if(num1).

See https://www.le.ac.uk/users/rjm1/cotter/page_37.htm

I don't think I can understand the conditional expression properly because the sauce is getting longer.

After refectoring the source, understand the conditional expression again, and if it doesn't work, please attach how the variables above are manipulated.


2022-09-21 16:09

I don't understand the question.

The above code is calculated as (num1!=0&&&num2!==0&&num1=num2) Two conditional expressions are calculated as ||

if ((num1 != 0 && num2 != 0 && num1 == num2) || (num1 != 0 && num2 != 0 && num1 == num2)) {}

This and

if ((num1 != 0 && num2 != 0 && num1 == num2)) {}

Is there a difference in this?

And the conditional expression above is

num1=1, num2=1 satisfies the condition.
After all, if num1, num2 is not 0 and is not 0, the condition is satisfied.


2022-09-21 16:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.