Comparison Operator in C++
For example
int a=5; int b=6; if(a==b) cout<<"a and b are equal"<<endl;There are three more Comparison Operator use in C++ which are given blew.
Less or Equal < =
Greater or Equal > =
Not Equal ! =
Example 1
#include<iostream.h> int main() { int a=5; int b=6; if(a==b) cout<<"a and b are equal"<<endl; if(a!=b) cout<<"a and b are not equal"<<endl; system("pause"); return 0; };
Example 2
#include<iostream.h> int main() { int a=5; int b=6; if(a==b) cout<<"a and b are equal"<<endl; if(a>=b) cout<<"a is greater then or equal to b"<<endl; if(a<=b) cout<<"a is less then or equal to b"<<endl; system("pause"); return 0; };Example 3
#include<iostream.h> int main() { int a=5; int b=6; if(a==b) cout<<"a and b are equal"<<endl; if(a!=b) cout<<"a and b are not equal"<<endl; system("pause"); return 0; };