C Programming Operators

C Programming Operators are the symbols used to perform mathematical and logical operations. You can use the C Operators on individual values or variables. The below table will show you the list of available C Programming operators with an example.

C Programming Operators Description
Arithmetic Operators The Arithmetic operators are used to perform basic mathematical calculations like Addition, Subtraction, Multiplication, Division, and Modulus. For more information, please refer to Arithmetic operators in C article
Relational OperatorsThe Relational operators are mostly used either in Loops or If Statements. Use Relational operators to check the relationship between the two variables. If the relationship is true, the operator will return 1. Otherwise, it will return value 0. For more information, please refer to Relational Operators in C article
Logical OperatorsThe Logical Operators are used to combine two or more conditions and perform the logical operations using Logical AND (&&), OR (||), and NOT (!).
Assignment OperatorsThe Assignment operators in C are used to assign the values to the declared variables. = (Equals) is the most commonly used assignment operator. For more information, Please refer Assignment Operators article
Increment & Decrement OperatorsIncrement and Decrement Operators used for increasing or decreasing the value by 1. ++ is used to increase the existing variable value by 1. The decrement operator – – is used to subtract or decrease the existing value by 1. For more information, please refer to Increment & Decrement Operators article
Bitwise OperatorsBitwise operators in C programming are used to perform bit operations. First, the decimal values will convert into a sequence of bits ( binary values) i.e., 0001, 1011 etc. And the bitwise operator will work on these bits like shifting them right to the left etc. For more information, please refer to Bitwise Operators in C article
Conditional OperatorThe Conditional Operator also known as the Ternary operator. We use Conditional Operators in the decision-making process. Depending upon the expression result, this operator returns the statement. Please visit the Conditional Operator in C to know the functionality.
Sizeof Operatorsizeof operator in C mostly used in finding the structure size, and array size. For more information, please refer to Sizeof Operator article

C Programming Arithmetic Operators Example

In this example, We are going to use two variables to perform various arithmetic operations in C programming Language

// Example for C Programming Operators
#include<stdio.h>

int main()
{
 int a = 24, b = 4;
 int addition, subtraction, multiplication, division, modulus;
 
 addition = a + b; 
 subtraction = a - b; 
 multiplication = a * b; 
 division = a / b; 
 modulus = a % b; 
 
 printf("Adding of two numbers a, b is : %d\n", addition);
 printf("Subtracting of two numbers a, b is : %d\n", subtraction);
 printf("Multiplying two numbers a, b is : %d\n", multiplication);
 printf("Division of two numbers a, b is : %d\n", division);
 printf("Modulus of two numbers a, b is : %d\n", modulus);

}
c-programming-operators-1

C Programming Operators – Relational Example

In this example, We are going to use two variables a and b to perform various relational operations in C programming.

#include <stdio.h>

main()
{
  int a = 35;
  int b = 16;
  
  printf("%d >  %d: %d \n", a, b, a > b);
  printf("%d >= %d: %d \n", a, b, a >= b);
  printf("%d <= %d: %d \n", a, b, a <= b);
  printf("%d <  %d: %d \n", a, b, a < b);
  printf("%d == %d: %d \n", a, b, a == b);
  printf("%d != %d: %d \n", a, b, a != b);

}

Output

35 >  16: 1 
35 >= 16: 1 
35 <= 16: 0 
35 <  16: 0 
35 == 16: 0 
35 != 16: 1 

C Programming Assignment Operators Example

For this example, We use the two variables x and Total. They will show you the working functionality of all the Assignment Operators in C Programming Language

#include <stdio.h>

int main()
{
 int x = 5;
 int Total = 25;

 printf(" Value of the Total = %d \n", Total += x );
 printf(" Value of the Total = %d \n", Total -= x );
 printf(" Value of the Total = %d \n", Total *= x );
 printf(" Value of the Total = %d \n", Total /= x );
 printf(" Value of the Total = %d \n", Total %= x );

 return 0;
}

Output

 Value of the Total = 30 
 Value of the Total = 25 
 Value of the Total = 125 
 Value of the Total = 25 
 Value of the Total = 0