8

I have seen and keyword being used inside if statement just like && operator. Is there any difference between these (and , &&) ?

#include <iostream>

using namespace std;

int main()
{
bool a = true;
bool b = true;

if(a==true and b==true) // if(a==true && b == true)
{
    cout << "YES ";
}


return 0;
}
Utshaw
  • 4,028
  • 2
  • 18
  • 24

2 Answers2

11

Yes, the new and keyword has been around since at least C++98. It operates identically to the && operator.

user1118321
  • 24,739
  • 4
  • 55
  • 82
8

There is no difference in and and &&. you can also use not instead of ! and or instead of ||.

Manvir
  • 699
  • 1
  • 7
  • 14