vendredi 20 mars 2020

IF & else syntax in C++

I don't understand how "if statement with OR " works.

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);

    char a = ')';

    if(a=='('|| '{') cout<< "true";
    else cout<<"false";

    return 0;

}

My first thought was that the result would be "false" but the program prints "true"

Aucun commentaire:

Enregistrer un commentaire