Written by Coursera Staff • Updated on

Learn about different types of operators and why they’re essential in computer programming, along with the different operator types in three popular languages.

Operators are symbols with defined functions. Programmers use these symbols to tell the interpreter or compiler in high-level computer languages, such as C++, Java, and Python, to perform a particular action. These symbols form the program's foundation, allowing you to perform various actions ranging from simple maths to complex encryption.

Operators are essential for performing calculations, assigning specific values to variables, and making condition-based decisions. You can learn more about operator types and how they work within three popular computer languages.

Different types perform different tasks within the programme. You can choose from three main types of operators, each with unique functions and capabilities.

Arithmetic operators allow computers to perform mathematical calculations on specific values. For example, you might write ‘A+B = 40’ or ‘A*B = 100’. Common arithmetic operators include:

Addition: +

Subtraction: -

Multiplication: *

Division: /

Integer division: DIV

Remainder: MOD

Relational operators facilitate condition testing, allowing you to create variables and assign them values. For example, if A equals 45 and B equals 50, you might write A < B or A is less than B. That < symbol is a relational operator that produces true or false results. Familiar relational operators include:

Assignment: =

Equivalence: ==

Less than: <

Greater than: >

Less than or equal to: <=

Greater than or equal to: >=

Does not equal: !=

Logical operators allow programmers to gain increasingly complex computer-based decisions by combining relational operators. For example, with the logical AND operator, if A equals 10 and B equals zero, and you write ‘A AND B is false,’ the condition is true if both variables are the same. If you use the logical OR operator and just one of the variables is something other than zero, ‘A OR B is true’ would be true.

You can reverse the variable’s logical state with the local NOT operator. So, what would otherwise be true becomes false and vice versa.

Common operators include:

AND (&&)

OR (||)

NOT (!)

C++ uses more than five types of operators to carry out different functions. You may also use multiple operators in one expression. In these cases, C++ has established operator precedence to determine how things get evaluated. For example, postfix operators work left to right. So do additive, multiplicative, and shift operators. Unary, conditional, and assignment operators have precedence from right to left. Types of C++ operators include:

**Assignment:**These operators assign the left-hand side operand the right-hand side operand's value and are variations on**=**, including**+=**(addition assignment),**-=**(subtraction assignment),***=**(multiplication assignment),**/=**(division assignment), and**%=**(modulus assignment)

**Arithmetic:**These operators allow you to perform calculations between two values using symbols such as**+**(addition),**-**(subtraction),*****(multiplication),**/**(division),**%**(modulus),**++**(increment), and**—**(decrement)

**Relational:**These operators perform comparisons between operands and include symbols like**==**equal to),**>**(greater than),**<**(less than),**!=**(not equal to),**>=**(greater than or equal), and**<=**(less than or equal to)

**Logical:**These C++ operators check conditions and expressions to determine whether they are true or false to aid decision-making. They include symbols like**&&**(logical AND operator if all operands are true),**||**(logical OR operator if at least one operand is true), and**!**(logical NOT operator that reverses the logical state from true to false or false to true)

**Bitwise:**These C++ operators allow you to perform operations by treating operands like a string of bits for output in decimals. Symbols include**&**(logical AND operator performs AND on the bits of two operands),**|**(logical OR operator performs OR on the bits of two operands),**^**(bitwise XOR operator performs XOR on all bits of two numbers),**~**(bitwise one complement inverts all an operand's bits),**<<**(binary left shift shifts the bits in one operand using the second operand as a determinant),**>>**(binary right shift shifts the bits in one operand using the second operand as a determinant)

**Other:**C++ also has other operators, including:**Size of**, which determines a variable's size**Conditional**, a ternary operator that evaluates test conditions and puts a code block into place based on test results**Comma,**which triggers the start of an operational sequence

In Java, you use operators to perform local operations and mathematical tasks. You can break them into three categories based on the number of operands or the entities they operate upon and use.** Unary** operators work on one operand, **binary** operators work on two operands, and **ternary** operators utilise three operands to carry out the task. Java’s operators include:

**Assignment:**This binary operator uses the symbol**=**to assign the value of the operand on the right of an expression to the one on the left.

**Arithmetic:**These operators may be unary and binary and get placed in three categories, including primary, increment and decrement, and shorthand. Symbols include**+**(addition),**-**(subtraction),*****(multiplication),**/**(division),**%**(modulus),**+**(unary plus to indicate a positive number), or**-**(unary minus to indicate a negative number)

**Increment and decrement**include**++**(increment) and**—**(decrement) to increment or decrement operands' values

**Shorthand**operators pair with assignment operators, making it possible to write less code by including symbols such as**+=**(addition assignment),**-=**(subtraction assignment), and***=**(multiplication assignment)

**Relational:**These binary operators work as comparison or equality operators and include symbols such as**>**(greater than),**<**(less than),**>=**(greater than equal to),**<=**(less than equal to),**==**(equal equal to), and**!=**(not equal to)

**Logical:**Java operators in this category work on boolean operands to perform functions using symbols like**&**(logical AND),**|**(logical OR),**!**(logical NOT),**^**(logical XOR),**==**(equal equal to),**!=**(not equal to),**&&**(conditional AND), and**||**(conditional OR)

**Bitwise:**To manipulate an operand's bits, you can use these operators, which include symbols like**&**(bitwise AND),**|**(bitwise OR),**~**(bitwise NOT), and**^**(bitwise XOR)

In Python, operators are symbols that perform specific tasks. The operator you choose for any operation changes the results, allowing you to manipulate operands' values. Python’s operators include:

**Arithmetic:**These operators include symbols that perform mathematical functions, including addition (**+**), subtraction (**-**), multiplication (*****), division (**/**), and modulus (**%**)

**Assignment:**These operators allow you to assign values and include various symbols, including**=**(X=2),**-=**(X-=2),**+=**(X+=2), and***=**(X*=2)

**Comparison:**When you want to compare two values, you will use symbols such as**=**(equal),**!=**(not equal),**>**(greater than), and**<**(less than)

**Logical:**When you want to compare conditional statements, you can use operators such as**x>2 and x>3**,**x>2 or x>3**, or**not (x>2 and x>3)**

**Membership:**These are operators that allow you to calculate and figure out if an object contains a sequence, including**in**, which comes back true in the presence of the sequence, or**not in**, which comes back as true if the sequence doesn't exist

**Bitwise:**These operators compare binary values using symbols such as**&**(sets all bits to 1 if all bits are 1),**|**(sets all bits to 1 if one of the bits is 1), or**^**(sets all bits for 1 if one of the bits is 1). To invert all bits, you could use**~**(Bitwise NOT), or you can use operators to shift left (**<<**) or shift right (**>>**)

**Identity:**The two identity operators include**is**(comes back true if both variables are the same objects) and**is not**(comes back true if the variables are different objects)

Operators are commonly used in computer programming, making programmers the primary career that uses them. You may use operators in other professions that require coding, including roles such as data analysts or data scientists.

Software engineers, data scientists, and data analysts are among India's most in-demand jobs [1]. Many applicants find positions in cities like Bangalore, sometimes called India’s Silicon Valley. Mumbai, Kolkata, and Delhi are common locations for these types of jobs. According to Glassdoor India, as of March 2024, the average base salaries for these careers are as follows:

**Programmers:**₹4,00,000**Data scientists:**₹12,59,927**Data analysts:**₹8,47,000

Now that you’re more familiar with the types of operators and how they work in different languages, continue learning to increase your skills and achieve your goals. For example, if you’re new to programming, consider earning a Professional Certificate, such as Google IT with Python, or completing a Specialisation like Learn SQL Basics for Data Science offered by the University of California Davis on Coursera.

If you have programming experience and want to brush up on operators, complete a Guided Project like JavaScript Variables and Assignment Operators on Coursera Project Network or Looker Functions and Operators, a Project that's part of Google Cloud Training—both on Coursera.

The Hindu. “With a Placement Rate of 93.5% Software Engineers have Witnessed a 120% Increase in Salary in 2021-2022, https://www.thehindu.com/brandhub/with-a-placement-rate-of-935-software-engineers-have-witnessed-120-increase-in-salary-in-2021-2022/article65370576.ece.” Accessed March 22, 2024.

Updated on

Written by:### Coursera Staff

C

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.