BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Arithmetic Operators in C with Examples

Last Updated: September 7, 2022 by Chaitanya Singh | Filed Under: c-programming

Arithmetic operators are used to perform arithmetic operations on the operands. For example, x + y is an addition arithmetic operation, where x and y are operands and + symbol is an arithmetic operator. C supports following arithmetic operators:
Arithmetic Operators in C

1. Addition(+) Operator Example

It adds two operands. In the following example, we have two integer variables and we are finding the sum of these numbers using + operator.

#include <stdio.h>
int main ()
{
  int x = 100, y =20;
  int sum;

  //Addition(+) operator
  //The addition result is stored in variable sum
  sum = x+y;

  //print result
  printf("Sum of %d and %d is: %d",x, y, sum);

  return 0;
}

Output:

Sum of 100 and 20 is: 120

2. Subtraction(-) Operator Example

The – operator is used for subtraction. Here, we are subtracting the value of y from the value of x. The subtraction result is stored in an int variable, which is displayed using printf() at the end of the program.

#include <stdio.h>
int main ()
{
  int x = 100, y =20;
  int sub;

  //Subtraction(-) operator
  //The result is stored in "sub"
  sub = x-y;

  //print subtraction result
  printf("x - y is: %d", sub);

  return 0;
}

Output:

x - y is: 80

3. Multiplication(*) Operator Example

The * operator is used for multiplication. It multiplies two operands as shown in the following program.

#include <stdio.h>
int main ()
{
  int x = 100, y =20;
  int product;

  //Multiplication(*) operator
  product = x*y;

  //print multiplication result
  printf("Multiplication of %d and %d is: %d", x, y, product);

  return 0;
}

Output:

Multiplication of 100 and 20 is: 2000

4. Division(/) Operator Example

The / operator, returns the quotient value after dividing left-side operand by right-side operand. For example, if 10 is divided by 5, then the / operator would return 2 (quotient).

#include <stdio.h>
int main ()
{
  int x = 100, y =20;
  int quotient;

  //Division(/) operator, it returns the quotient after
  //dividing x by y
  quotient = x / y;

  //print Division result
  printf("Quotient value after dividing %d by %d is: %d", x, y, quotient);

  return 0;
}

Output:

Quotient value after dividing 100 by 20 is: 5

5. Modulus(%) Operator Example

The % operator returns the remainder after dividing the left-side operand by right-side operand. For example, 10 % 2 would return 0 as 10 is perfectly divisible by 2.

#include <stdio.h>
int main ()
{
  int x = 100, y =20;
  int rem;

  //Modulus(%) operator, it returns the remainder after
  //dividing x by y
  rem = x % y;

  //print Modulus result
  printf("Remainder value after dividing %d by %d is: %d", x, y, rem);

  return 0;
}

Output:

Remainder value after dividing 100 by 20 is: 0
❮ C Tutorial

Top Related Articles:

  1. Unary Operator in C with Examples
  2. Conditional (Ternary) Operator in C with Examples
  3. C – loops in C programming with examples
  4. Assignment Operators in C with Examples
  5. C – Pointer to Pointer (Double Pointer) with example

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

C Programming Tutorial

  • C Tutorial
  • History of C
  • Features of C
  • Turbo C++ installation
  • First C Program
  • printf scanf
  • Variables in C
  • Data Types in C
  • C - Keywords
  • C Identifiers
  • C Comments
  • Operator precedence
  • C - if statement
  • C - if..else
  • C - for loop
  • C - while loop
  • C - do while loop
  • C - continue
  • C - break statement
  • C - switch..case
  • C - goto statement
  • C - Arrays
  • 2 D array
  • C - String
  • C - functions
  • Function call by reference
  • Function call by value
  • Array to function
  • C - Structures
  • C - Pointers
  • Pointer to Pointer
  • Pointers to functions
  • C - function pointers
  • Pointer & Array
  • C - File I/O
  • C Programming Examples

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap