-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharithmetic.html
124 lines (83 loc) · 2.4 KB
/
arithmetic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// let a = 9, b = 7;
// let c = a + b;
// console.log("a + b = " + c);
// console.log("a - b = " + (a - b));
// console.log("a * b = " + (a * b));
// console.log("a / b = " + (a / b));
// console.log("a % b = " + (a % b));
// console.log("a++ => " + a++);
// console.log("a => " + a);
// console.log("++a => " + ++a);
let num1 = parseInt(prompt("Enter first number:"));
let num2 = parseInt(prompt("Enter second number:"));
let sum = num1 + num2;
console.log("sum = " + sum);
/* Operators in JavaScript
1. Arithmetic Operators :
+ , - , * , / , % ++ (increment-operator) , -- (decrement-operator)
a++ ; , a = a+1
suppose a=3
a++; ... value show 3 but saved in memory 4
++a; 5 show and saved in memory ..
Operands :
For example, in "1 + 2" the "1" and "2" are the operands and the plus symbol is the operator.
a+b; a and b are operands
Operators :
arithmetic operators. relational operators. logical operators ( AnD ,OR ,Not also called Bollean Operator)
Expression :
expression:
1. (a+b) - c;
2. (2*5)+(2*6);
Example :
1. a = 10;
a is variable and 7 is literalls.
a+b; where a and b are operands and + is an operator
a=8; = Means Assignment operator
2. Relational-Operator :
< , > , <= , >= , != , ==
10>2 true;
10<=3 false;
10>=4 true;
10==10 true
19!=20 true;
a=10; 10 is assign to a in computer memory..
OPERATOR PRECEDENCE :
Operators Precedence
1. ! (Logical Not) Highest
2. * ,/ , %
3. + , -
4. < , <= > , >=
5. == ,!=
6. && (And)
7. || (OR)
8. = (Assignment) Lowest
Assignment Operators
Arithmetic Operators
Comparison Operators
Logical Operators
Bitwise Operators
String Operators
Other Operators
parseInt is used to change string value into the integer (+ interpretor confuse sometimes concetinate)
"" higher precedence in js
and then ()
+ , - same precendence.
parseInt(string)
prompt...user enter any value...input
console.log...print
prompt...input
litterls vs Constant
*/
</script>
</body>
</html>