Difference between logical operator and arithmetic operator
Answers
Answered by
2
S has simple arithmetic operators that work in a fairly intuitive manner. The symbols for addition, subtraction, multiplication, division, and exponentiation are respectively: +, -, *, /, ^. For example:
> x <- 1:5
> x
[1] 1 2 3 4 5
> x+3 # add 3 to each element of x
[1] 4 5 6 7 8
> x*x # multiply each element of x by itself
[1] 1 4 9 16 25
> x^3 # raise each element of x to the third power
[1] 1 8 27 64 125
S uses the following logical operators:
> greater than
< less than
== equal to
!= not equal to
>= greater than or equal to
<= less than or equal to
& and
| or
The result of a logical operation is `T' (true) or `F' (false), or a vector of `T's and `F's. As we shall see in the next section, this is very useful for working with subsets of our data. Examples:
> x
[1] 1 2 3 4 5
> x <= 2
[1] T T F F F
> x == 1 | x > 4
[1] T F F F T
> x <- 1:5
> x
[1] 1 2 3 4 5
> x+3 # add 3 to each element of x
[1] 4 5 6 7 8
> x*x # multiply each element of x by itself
[1] 1 4 9 16 25
> x^3 # raise each element of x to the third power
[1] 1 8 27 64 125
S uses the following logical operators:
> greater than
< less than
== equal to
!= not equal to
>= greater than or equal to
<= less than or equal to
& and
| or
The result of a logical operation is `T' (true) or `F' (false), or a vector of `T's and `F's. As we shall see in the next section, this is very useful for working with subsets of our data. Examples:
> x
[1] 1 2 3 4 5
> x <= 2
[1] T T F F F
> x == 1 | x > 4
[1] T F F F T
Answered by
2
Logical operator is represented by '&&'.
They allow a program to make a decision based on multiple conditions. Each operand is considered a condition that can be evaluated to a true or false value.
Arithmetic operators take numerical values as their operands and return a single numerical value.
HOPE IT HELPS
They allow a program to make a decision based on multiple conditions. Each operand is considered a condition that can be evaluated to a true or false value.
Arithmetic operators take numerical values as their operands and return a single numerical value.
HOPE IT HELPS
Similar questions
Social Sciences,
7 months ago
India Languages,
7 months ago
Geography,
1 year ago
Social Sciences,
1 year ago
Math,
1 year ago