896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

JavaScript Tutorial : Introduction to operators in JavaScript - Javascript Arithmetic Operators

Introduction To Operators in JavaScript
1→ Arithmetic Operators
2→ Comparison Operators
3→ Logical Operators
4→ Assignment Operators
5→ Condition Operators

Arithmetic Operators :

Operators   Description         Example
+                   Addition             var c = a + b;
-                    Subtraction        var c = a - b;
*                   Multiplication    var c = a * b;
/                    Division             var c = a / b;
%                  Modulus             var c = a % b;
++                 Increment           var c = ++a;
–                    Decrement         var c = -- a;

Examples on Arithmetic Operator : 

Addition Example:-
<html> 
 <head> 
   <body> 
      <script > 
          var b = 10,c = 15; 
          var a = b + c; 
          document.write(a); 
      </script> 
    </body> 
  </head> 
</html>
Output : 25

Subtraction Example:-
<html> 
 <head> 
   <body> 
      <script > 
          var b = 10,c = 5; 
          var a = b - c; 
          document.write(a); 
      </script> 
    </body> 
  </head> 
</html>
Output : 5

Multiplication Example:-
<html> 
 <head> 
   <body> 
      <script > 
          var b = 2,c = 3; 
          var a = b * c; 
          document.write(a); 
      </script> 
    </body> 
  </head> 
</html>
Output : 6

Division Example:-
<html> 
 <head> 
   <body> 
      <script > 
          var b = 10,c = 5; 
          var a = b / c; 
          document.write(a); 
      </script> 
    </body> 
  </head> 
</html>
Output : 2

Modulus Example:-
<html> 
 <head> 
   <body> 
      <script > 
          var b = 10,c = 5; 
          var a = b % c; 
          document.write(a); 
      </script> 
    </body> 
  </head> 
</html>
Output : 0

Increment Example:-
<html> 
 <head> 
 </head> 
  <body> 
   <script > 
     var b = 10,c = 5; var a = ++b;//pre-increment b++;//post-increment 
     var e =b; 
     document.write(a); 
     document.write('<br>'); //using HTML code 
     document.write(e); 
    </script> 
   </body> 
</html>
Output : 11
12

Decrement Example:-
<html> 
 <head> 
 </head> 
  <body> 
   <script > 
     var b = 10,; 
     var a = --b; 
     document.write(a); 
    </script> 
   </body> 
</html>
Output : 9

JavaScript Introduction Part 1 : Checkout : Part 1

JavaScript Introduction Part 2 : Checkout : Part 2

JavaScript Introduction Part 3 : Checkout : Part 3
About Developer
Konakalla Premsai
I love to make things simple :)

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

Post a Comment

Previous Post Next Post

Contact Form