mardi 3 décembre 2019

What is if(i | j) and if (i & j) doing in C++

Hello after learning C++ for several months I decided to look at some CPA practice questions and the very first question threw me off with this code.

#include <iostream>
using namespace std;
int main(void) {
 int i = 1, j = 2;
 if(i > j && j > i)
     i++;
 if(i > j || j > i)
     j++;
 if(i | j)
     i++;
 if(i & j)
     j++;
 cout << i * j << endl;
 return 0;
}

What I don't understand is what the third and fourth if statements are looking for because I have never seen that syntax before. Thank You!

Aucun commentaire:

Enregistrer un commentaire