How to use arithmetic operators in c language

Arithmetic Operators

On this page

Arithmetic Operators

Program to use Arithmetic Operators in C Language

#include<stdio.h>
  int main()
  {
    int a = 12, b = 6,res;
    res = a + b;
    printf("Sum : %d\n", res);
    res = a - b;
    printf("Difference : %d\n", res);
    res = a * b;
    printf("Product : %d\n", res);
    res = a/b;
    printf("Quotient : %d\n", res);
    res = a%b;
    printf("Remainder : %d\n", res);
    return 0;
  }
  

Output

Sum : 18
  Difference : 6
  Product : 72
  Quotient : 2
  Remainder : 0
  

Steps Description

  • Declare integer three variable a,b and res
  • Initialize in integer variable a=12, b=6
  • Assign res variable with sum of variable a and b
  • printf inbuild function display res variable with decimal placeholder %d
  • Assign res variable with difference of variable a and b
  • printf inbuild function display res variable with decimal placeholder %d
  • Assign res variable with product of variable a and b
  • printf inbuild function display res variable with decimal placeholder %d
  • Assign res variable with quotient of variable a and b
  • Assign res variable with difference of variable a and b
  • printf inbuild function display res variable with decimal placeholder %d
  • Assign res variable with remainder of variable a and b
  • printf inbuild function display res variable with decimal placeholder %d