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;
}
Yes, the new and keyword has been around since at least C++98. It operates identically to the &&
operator.
There is no difference in and
and &&
. you can also use not
instead of !
and or
instead of ||
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With