Function:-Arthmatic Operation
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <script type="text/javascript">
- //Function Arthmatic Operation
- //Addition
- function add(a , b) //function name must start with letter or underscore.
- {
- var c = a + b;
- document.write("the add is:"+c+"<br>");
- }
- add(40, 50); //Function Call:- You can many times call function.
- add (45, 45); //you can add many argumentsas you want.
- //Subtraction
- function sub(a , b)
- {
- var c = a - b;
- document.write("the sub is:"+c+"<br>");
- }
- sub(100, 50); //100, 50 this value store in 'a' and 'b', then execute operation "100 - 50= 50".
- //Division
- function div(a , b)
- {
- var c = a / b;
- document.write("the div is:"+c+"<br>"); // +c+ is used to indicate which value should be print.
- }
- div(100, 4);
- //Multiplication
- function multi(a , b)
- {
- var c = a * b;
- document.write("the multi is:"+c+"<br>"); // document.write() use for print line.
- }
- multi(100, 11);
- //Modulus
- function mod(a , b)
- {
- var c = a % b;
- document.write("the modulos is:"+c+"<br>"); //"<br>" use for linebreak.
- }
- sub(500, 5);
- </script>
- </body>
- </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