हिंदी
तमिलनाडु बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान कक्षा ११

Explain about the Arithmetic operator with suitable example.

Advertisements
Advertisements

प्रश्न

Explain about the Arithmetic operator with suitable example.

दीर्घउत्तर
Advertisements

उत्तर

JavaScript supports all the basic arithmetic operators like addition (+), subtraction (–), multiplication (*), division (/), and modulus (%, also known as the remainder operator).

Arithmetic Operators:

Arithmetic Operator Meaning Example Result
+ Addition var sum = 20 + 120 Variable sum = 140
- Subtraction var diff = 20 - 120 Variable diff = 100
* Multiplication var prod = 10 * 100 Variable prod = 1000
/ Division var res = 100/522 Variable res = 5.22
% Modulus operator var rem = 100 % 522 Variable rem = 22 (remainder)

HTML CODE Using Arithmetic Operators:

<Html>
<Head>
     <Title>Demo Program – To test Arithmetic Operators in JavaScript
</Title>
</Head>
<Body>
      <script language="javascript" type="text/javascript">
      var value1 = 522, value2=10;
      document.write("<br>Data1 : "+value1);
      document.write("<br>Data2 : "+value2);
      var sum = value1+value2;
      var diff = value1-value2;
      var prod = value1*value2;
      var res = value1/value2;
      var rem = value1%value2;
      document.write("<br><br>The Sum of Data1 and Data2 : "+sum);
      document.write("<br>The Difference of Data1 and Data2 : "+diff);
      document.write("<br>The Product of Data1 and Data2 : "+prod);
      document.write("<br>The Result after Division of Data1 and Data2 : "+res);
      document.write("<br>The Remainder after Division of Data1 and Data2 :
"+rem);
</script>
</Body>
</Html> 

Output:

shaalaa.com
Javascript Operators and Expressions
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 14: Introduction to Javascript - Evaluation [पृष्ठ ३१४]

APPEARS IN

सामाचीर कलवी Computer Applications [English] Class 11 TN Board
अध्याय 14 Introduction to Javascript
Evaluation | Q 2. | पृष्ठ ३१४
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×