⏱️ 6min read
Difficulty level: Easy
160K+ career-aspirant learners have read this article 👨🏻‍💻 on C Operators!

C operators are one of the features in C which has symbols that can be used to perform mathematical, relational, bitwise, conditional, or logical manipulations. The C programming language has a lot of built-in operators to perform various tasks as per the need of the program. Usually, operators take part in a program for manipulating data and variables and form a part of the mathematical, conditional, or logical expressions.

🕵🏻‍♂️ Did You Know?

Some of the most-asked interview questions for C Programming roles are: 

  1. What is the difference between an array and a pointer in C?
  2. How do I declare an array in C?
  3. How do I access array elements in C?

Have a great start to finding the answers & strengthening your C programming skills by availing this free course on ‘C Basics Online Tutorial Course for Beginners’ with a SkillUp verified certificate 📃upon completion.

In other words, we can also say that an operator is a symbol that tells the compiler to perform specific mathematical, conditional, or logical functions. It is a symbol that operates on a value or a variable. For example, + and - are the operators to perform addition and subtraction in any C program. C has many operators that almost perform all types of operations. These operators are really useful and can be used to perform every operation.

Additionally, you can also learn more about the uses of C language.

Arithmetic Operator With Example

Arithmetic Operators are the operators which are used to perform mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). It performs all the operations on numerical values (constants and variables).

The following table provided below shows all the arithmetic operators supported by the C language for performing arithmetic operators.

Operator

Description

  • (Addition)

It adds two operands

− (Subtraction)

It subtracts second operand from the first

* (Multiplication)

It multiplies both operands

/ (Division)

It is responsible for dividing numerator by the denomerator

% (Modulus)

This operator gives the remainder of an integer after division

Enroll in this free course on C Basics now, unlock the verified certificate & become job-ready for Programmer/ Developer roles!

Let’s look at an example of arithmetic operations in C below assuming variable a holds 7 and variable b holds 5.

// Examples of arithmetic operators in C

#include <stdio.h>

int main()

{

    int a = 7,b = 5, c;    

    c = a+b;

    printf("a+b = %d \n",c);

    c = a-b;

    printf("a-b = %d \n",c);

    c = a*b;

    printf("a*b = %d \n",c);

    c = a/b;

    printf("a/b = %d \n",c);

    c = a%b;

    printf("Remainder when a is divided by b = %d \n",c);   

    return 0;

}

Output:

a+b = 12

a-b = 2

a*b = 35

a/b = 1

Remainder when a divided by b = 2

The operators shown in the program are +, -, and * that computes addition, subtraction, and multiplication respectively. In normal calculation, 7/5 = 1.4. However, the output is 1 in the above program. The reason behind this is that both the variables a and b are integers. Hence, the output should also be an integer. So, the compiler neglects the term after the decimal point and shows 2 instead of 2.25 as the output of the program.

Showcase a verified certificate of completion on your resumé to advance your Programming/ Developer career by 2X faster with salary hike