Home > Net >  I'm trying to correct this error but I don't know where is the problem
I'm trying to correct this error but I don't know where is the problem

Time:01-27

why is this code giving and error in the {} after the if. here is the code ( The error is {, I highlighted"

#include <iostream>
#include <stdio.h>

int main() {
    int A = 5, B = 3, C = -12;
        
    if (A   B == 8)  (A - B == 2) **{**
        std::cout << "Verdadero/n";
    }
    else
    {
        std::cout << "Falso/n";
    }
    
    return 0;
}

CodePudding user response:

if (A) (B) { 
   ...
}

Is not valid syntax. If you want to find out if A or B is true, then you may want:

if (A || B) {
    ...
}

If you're trying to find if they're both true, use && rather than ||.

CodePudding user response:

you should add the (AND "&&" or OR "||") operator between the two operation

CodePudding user response:

Use && (and operator) to combine multiple conditions.

If statement only accept a bool expression.

If (a b == 8 && a-b == 2)

  •  Tags:  
  • Related