CodesJava

Easy learning with example program codes

TypeScript Arithmetic Operators Tutorial

TypeScript Arithmetic Operators:

Arithmetic operators are used to perform arithmetic operations.

TypeScript Arithmetic Operators List:

OperatorDescriptionExample
+Addition30+20 = 50
Subtraction30-10 = 20
*Multiplication10*10 = 100
/Division50/10 = 5
%Modulus (Remainder)50%7 = 1
++Incrementvar a=10; a++; Result into a = 11
Decrementvar a=10; a–; Result into a = 9

TypeScript Arithmetic Operators Example:

var num1:number = 20;
var num2:number = 4;
var result:number = 0;
 
result = num1 + num2;
console.log("Sum: "+result); 
 
result = num1 - num2; 
console.log("Difference: "+result);
 
result = num1*num2;
console.log("Product: "+result);
 
result = num1/num2;
console.log("Quotient: "+result);
 
result = num1%num2;
console.log("Remainder: "+result);
 
num1++ 
console.log("Value of num1 after increment: "+num1);
 
num2-- 
console.log("Value of num2 after decrement: "+num2);

 

Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status