I just started learning C++ and I have to solve this problem: Let be x an integer variable. For what values of x does the expression x+7==8*x take the value 1.
Thank you
in c++ the keyword true is 1 and the keyword false is zero.
In reverse, though, it opens up: anything that can be evaluated to zero is false, *else* it is true, so 7 is true, 'x' is true, 0.0 is false.
so your expression evaluates to true (1) when both sides are equal. Solving it, you see that
when x is 1, the expression is true: 1+7 is = to 8*1
that leaves me unsure of what the teacher wants. 1 is the answer to the equation/math part AND the result of the boolean expression. To clarify that, lets look at this one:
F == (F - 32) * 5/9
here, it turns out that -40 gives a result of (true) which is (1). -40 is the math part, and (1) or (true) is the boolean portion. (extra credit if you know why this specific equation is "cool").
We are learning about C++ operators and I have two problems to solve:
-1.The first one, what I posted, I can't understand why its written ”values of X” and not value of X.
2.In the second one, the requirements of the problem are the same, only the expression differs: 2*x+3==6 (I have to find x values for which this expression gives 1)
1) that is just mathspeak. x is a variable. It could be 23. It could be -100013. But those values do not give an answer of '1' for the given math. It wants to know what value(s) do give that result. Even if there is only one answer, mathspeak uses the plural here -- this is an acknowledgment that until you solve it you do not know if there is 0, 1, 2, or many solutions to the problem. Consider x*x == 4; (there are 2 answers now)
2) well, give it a try. it is not an integer result. You cannot find it in code without using a double or other floating point type :) If it said 'integer' somewhere in your text, then the answer is 'none'.