How to use arithmetic operators in c language

program to use arithmetic operators in c language


 #include<stdio.h>
int main()
{
    int a=17,b=4;
    printf("sum=%d\n",a+b);
    printf("Difference=%d\n",a-b);
    printf("product=%d\n",a*b);
    printf("quotient=%d\n",a/b);
    printf("Remainder=%d\n",a%b);
    return 0;
}

output


sum=21       
Difference=13
product=68   
quotient=4   
Remainder=1

How to use Arithmetic operators in C Language

Program to use Arithmetic operators in C Language


#include <stdio.h>
int main()
{
    int a = 17, b = 4;
    printf("sum=%d\n", a + b);
    printf("defference=%d\n", a - b);
    printf("proudct=%d\n", a * b);
    printf("quotient=%d\n", a / b);
    printf("remainder=%d\n", a % b);
    return 0;
}

output


sum=21
difference=13
product=68
quotient=4
remainder=1

How to use Arithmetic Operators JavaScript Language

Program to use Arithmetic Operator (-, +, *, **, /, %, – -, ++) Javascript Language


let a = 5;
let b = 3;
let c;

//subtraction oprater (-)
c = a - b;
console.log('c = ', c);
// Output c =  2

//addition oprater (+)
c = a + b;
console.log('c = ', c);
// Output c =  8


//multiplication oprater (*)
c = a * b;
console.log('c = ', c);
// Output c = 15

//exponentiation oprater (**)
c = a ** b;
console.log('c = ', c);
// Output c = 125

//division oprater (/)
c = a / b;
console.log('c = ', c);
// Output c =  1.6666666666666667

//modulus (remainder) oprater (%)
c = a % b;
console.log('c = ', c);
// Output c = 2

//decrement oprater (--)
console.log('a = ',a)
console.log('--a = ',--a)
console.log('a-- = ',a--)
// Output a =  5 , --a = 4 , a-- = 4


//increment oprater (++)
console.log('b = ',b)
console.log('++b = ',++b)
console.log('b++ = ',b++)
// Output b = 3 , ++b = 4 , b++ = 4

Output


c =  2
c =  8
c =  15
c =  125
c =  1.6666666666666667
c =  2
a =  5
--a =  4
a-- =  4
b =  3
++b =  4
b++ =  4