Advertisement



< Prev
Next >



C - Relational Operators










This operator is also knows an not equal to operator. It compares between the values of its two operands by checking for their inequality. It returns a boolean value true when operands have unequal values otherwise it returns false.




A coding example with != operator


/* A coding example with != operator */

#include<stdio.h>

int main()
{
if('z' != 'a') 		/* comparing a character to another character */
printf("z is not equal to a \n");


if(100 != 100.001)	/* comparing an int with a double */
printf("100 is not equal to 100.001 \n");


if(99.9999 != 99.999)	/* comparing a double with a double */
printf("99.9999 is  not equal to 99.999 \n");


if(5.00 != 5.0)		/* comparing an int to double */
printf("5.00 is not equal to 5.0 \n");

if(11 !=10)
printf("11 is not equal to 10 \n");

if(98 != 'a')		/* comparing int to ASCII value of a character */
printf("98 is not equal to a");

return 0;
}


Output -


z is not equal to a
100 is not equal to 100.001
99.9999 is  not equal to 99.999
11 is equal to 10
98 is equal to a
Note : There should never be any space between ! and = of != operator, or a compile error is thrown.



Please share this article -





< Prev
Next >
< Compound Assignment Operators in C
Logical Operators in C >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement