Operators in C++

Google Advertisements

Prev Tutorial Next Tutorial

Operators in C++

Operator is a special symbol that tells the compiler to perform specific mathematical or logical Operation.

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Ternary or Conditional Operators
operators

Arithmetic Operators

Given table shows all the Arithmetic operator supported by C Language. Lets suppose variable A hold 8 and B hold 3.

OperatorExample (int A=8, B=3)Result
+A+B11
-A-B5
*A*B24
/A/B2
%A%40

Relational Operators

Which can be used to check the Condition, it always return true or false. Lets suppose variable A hold 8 and B hold 3.

OperatorsExample (int A=8, B=3) Result
<A<BFalse
<=A<=10True
>A>BTrue
>=A<=BFalse
==A== BFalse
!=A!=(-4)True

Logical Operator

Which can be used to combine more than one Condition?. Suppose you want to combined two conditions A<B and B>C, then you need to use Logical Operator like (A<B) && (B>C). Here && is Logical Operator.

OperatorExample (int A=8, B=3, C=-10)Result
&&(A<B) && (B>C)False
||(B!=-C) || (A==B)True
!!(B<=-A)True

Truth table of Logical Operator

C1C2C1 && C2 C1 || C2!C1!C2
TTTTFF
TFFTFT
FTFTTF
FFFFTT

Assignment operators

Which can be used to assign a value to a variable. Lets suppose variable A hold 8 and B hold 3.

OperatorExample (int A=8, B=3)Result
+=A+=B or A=A+B11
-=A-=3 or A=A+35
*=A*=7 or A=A*756
/=A/=B or A=A/B2
%=A%=5 or A=A%53
=a=bValue of b will be assigned to a

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483 Try this Keyword C++ Programs