Parul takes as input two numbers: a and b. a and b can take integer values
between 0 and 255. She stores a, b and c as 1-byte data type. She writes the
following code statement to process a and b and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b,
while gives an erroneous answer for others. For which of the following inputs will it
give a wrong answer?
Answers
Answered by
7
Answer:
value of "a" can be anything upto 255, but the value of "b" should be upto 127.
Explanation:
since variables can store value upto 255 and in the expression value of "b" is multiplied by 2. so if value of "b" is more than 127 it will exceed the range of 255.
Similar questions