C++ 'not_eq' Keyword with Example

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

"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.

Example:

    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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.