Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'and' keyword in C++ [duplicate]

Tags:

c++

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;
}
like image 811
Utshaw Avatar asked Jun 06 '17 04:06

Utshaw


2 Answers

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

like image 154
user1118321 Avatar answered Nov 06 '22 12:11

user1118321


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

like image 43
Manvir Avatar answered Nov 06 '22 12:11

Manvir