Skip to main content

//Function:-Arthmatic Operation

Function:-Arthmatic Operation


  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. </head>
  7. <body>
  8. <script type="text/javascript">
  9. //Function Arthmatic Operation
  10. //Addition
  11. function add(a , b) //function name must start with letter or underscore.
  12. {
  13. var c = a + b;
  14. document.write("the add is:"+c+"<br>");
  15. }
  16. add(40, 50); //Function Call:- You can many times call function.
  17. add (45, 45);  //you can add many argumentsas you want.

  18. //Subtraction
  19. function sub(a , b) 
  20. {
  21. var c = a - b;
  22. document.write("the sub is:"+c+"<br>");
  23. }
  24. sub(100, 50); //100, 50 this value store in 'a' and 'b', then execute operation "100 - 50= 50".

  25. //Division
  26. function div(a , b) 
  27. {
  28. var c = a / b;
  29. document.write("the div is:"+c+"<br>"); // +c+ is used to indicate which value should be print.

  30. }
  31. div(100, 4);

  32. //Multiplication
  33. function multi(a , b) 
  34. {
  35. var c = a * b;
  36. document.write("the multi is:"+c+"<br>"); // document.write() use for print line.
  37. }
  38. multi(100, 11);

  39. //Modulus
  40. function mod(a , b) 
  41. {
  42. var c = a % b;
  43. document.write("the modulos is:"+c+"<br>"); //"<br>" use for linebreak.
  44. }
  45. sub(500, 5);
  46. </script>
  47. </body>
  48. </html>



//Execute


//Output

/*

the add is:90

the add is:90

the sub is:50

the div is:25

the multi is:1100

the sub is:495


*/



                                                               //ThE ProFessoR