• Home
  • Operators in C Language

Operators in C Language

In C, operators are used to perform operations on variables and values. There are several types of operators in C, including:

  1. Arithmetic operators: These operators are used to perform arithmetic calculations, such as addition, subtraction, multiplication, and division. For example:
int a = 5;

int b = 2;

int c = a + b; // c is now 7
  1. Comparison operators: These operators are used to compare two values and return a Boolean value (either true or false). For example:
int a = 5;

int b = 2;

if (a > b) { // this condition is true // code goes here }
  1. Logical operators: These operators are used to perform logical operations, such as AND, OR, and NOT. For example:
int a = 5;

int b = 2;

if (a > 0 && b < 10) { // this condition is true // code goes here }
  1. Assignment operators: These operators are used to assign a value to a variable. For example:
int a = 5;

a = 10;

// a is now 10
  1. Increment and decrement operators: These operators are used to increase or decrease the value of a variable by 1. For example:
int a = 5;

a++; // a is now 6

It is important to understand the different types of operators in C and how to use them correctly in your programs. Using the appropriate operator can help to ensure that your code is efficient and free of errors.