Ads

Operators are symbols that tell the compiler to perform specific mathematical or logical manipulation

Types of operators:

  • Arithmetic Operator
  • Relational Operator 
  • Bitwise Operator 
  • Logical Operator 
  • Assignment Operator
  • Increment/Decrement Operator
  • Conditional Operator


Arithmetic Operators:



In above program i used two variables a and b for doing all arithmetic operations. here see the output difference between division (/) and modulo division (%).

Output:

Use floating point for division , u will get better results with precision.

Relational Operator:

These operators are used for comparison. They return either true (1) or false(0)  based on the comparison result. The operator '==' should not be confused with '='. The relational operators are as follows:


Sample Program:

a>b is it true?, Value 10 bigger than 5, so output return 1 here
a<b is it true?, Value 10 lesser than 5,is not crt. so output return 0 here.
a>=c,is it true?,value 10 greater than or  equal to 10.Here 10>10 or 10==10 is a condition u have check,so output return 1 here.
a<=b is it true?, value 10 lesser than or equal to 5.here 10<5 or 10==5 condition u have to check,so output returns 0 here.
a!=c is it true? value 10 not equal to value 10. here first check two values are equal then reverse the output. here 10==10 is true, but output return 0 because of ! operation.(! is NOT operator)
a==c is it true? value 10 equal to value 10. yes two values are equal then it returns 1.

Output:

Comments

Popular posts from this blog

Datatypes in C

Ethical Hacking V10

Installing Anaconda on Windows.