C Language

May 25, 2023

How to use arithmetic operators in c language

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

  1. Declare integer three variable a,b and res
  2. Initialize in integer variable a=12, b=6
  3. Assign res variable with sum of variable a and b
  4. printf inbuild function display res variable with decimal placeholder %d
  5. Assign res variable with difference of variable a and b
  6. printf inbuild function display res variable with decimal placeholder %d
  7. Assign res variable with product of variable a and b
  8. printf inbuild function display res variable with decimal placeholder %d
  9. Assign res variable with quotient of variable a and b
  10. printf inbuild function display res variable with decimal placeholder %d
  11. Assign res variable with remainder of variable a and b
  12. printf inbuild function display res variable with decimal placeholder %d

by : Ajaj Khan

Quick Summary:

use arithmetic operators in c language