Home »
C++ programming language
C++ 'not_eq' Keyword with Examples
C++ | 'not_eq' keyword: Here, we are going to learn about the 'not_eq' keyword which is an alternative to NOT EQUAL TO operator.
Submitted by IncludeHelp, on May 16, 2020
C++ 'not_eq' Keyword
"not_eq" is an inbuilt keyword that has been around since at least C++98. It is an alternative to != (NOT EQUAL TO) operator and it mostly uses with the conditions.
The not_eq keyword returns 1 if operand_1 is not equal to the operand_1, and it returns 0 if operand_1 is equal to the operand_2.
Syntax
operand_1 not_eq operand 2;
Here, operand_1 and operand_2 are the operands.
Sample Input and Output
Input:
a = 10;
b = 20;
result = a not_eq b;
Output:
result = 1
C++ example to demonstrate the use of "not_eq" keyword
// C++ example to demonstrate the use of
// 'not_eq' operator.
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int b = 20;
cout << "a: " << a << endl;
cout << "b: " << b << endl;
if (a not_eq b)
cout << a << " is not equal to " << b << endl;
else
cout << a << " is equal to " << b << endl;
a = 20;
b = 20;
cout << "a: " << a << endl;
cout << "b: " << b << endl;
if (a not_eq b)
cout << a << " is not equal to " << b << endl;
else
cout << a << " is equal to " << b << endl;
return 0;
}
Output
a: 10
b: 20
10 is not equal to 20
a: 20
b: 20
20 is equal to 20