3.
Predict the output of the following operations if x = -5 and y=3 initially
a. -X
f. x+y
g. x%y
b. -y
c. -X + -y
d. -X - y
h. x/y
i. x *-y
e. x % -11
j. -X % -5
Answers
Answer:
a) 5
b) -2
c) -0.15
d) -3
e) +2
f) +2
g) 5/3 = 1.67
h) -5*-3 = 15
i) -5%-11 = -11.05
j) 5%-5 = -4.95
Explanation:
i hope this is the correct answer. not sure
Predict the output of the following operations if x = -5 and y=3 initially
a. -X; b. -y; c. -x + -y; d. -x - y; e. x % -11; f. x+y; g. x%y; h. x/y; i. x *-y; j. -X % -5
a. 5; b. -3; c. +2; d. +2; e. -5; f. -2; g. -2; h. -1; i. 15; j. 0
Given:
x = -5 and y = 3
To Find:
The values of-
a. -X
b. -y
c. -x + -y
d. -x - y
e. x % -11
f. x+y
g. x%y
h. x/y
i. x *-y
j. -X % -5
Solution:
Let, all these operations have been done in C++.
We have,
x = -5
y = 3
a) Here negetive and negative are creating a positive value.
-x = -(-5)
or, -x = 5
b) Here positive and negative are creating a negative value.
-y = -3
c) -x + -y = -(-5) + -(3)
or, -x + -y = 5-3
or, -x + -y = +2
d) -x - y = -(-5) - (3)
or, -x -y = 5-3
or, -x -y = +2
e) % is a modulus operator.
x % -11 = -5
f) x+y = (-5) + (3)
or, x+y = -2
g) Moldulo Operator % also known as Modulus or Modular or Modulo Division operator in C. It gives the remainder of a division.
x%y = -2
h) x/y = -5/3
= -1.66667 [if the integers are taken as float variable]
or the result will be x/y = -1 if variables are taken as integer data type.
i) x *-y = 15
as * operator multiplies two variables.
j) -x % -5 = 0
Which means there will be no remainder in it.
a. 5; b. -3; c. +2; d. +2; e. -5; f. -2; g. -2; h. -1; i. 15; j. 0
#SPJ2