11

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,166
  • 3
  • 20
  • 25

2 Answers2

20

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

user1118321
  • 25,567
  • 4
  • 55
  • 86
14

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

Manvir
  • 769
  • 1
  • 7
  • 15