*What is the exact value of each variable after each specific line of code is ru
ID: 3678439 • Letter: #
Question
*What is the exact value of each variable after each specific line of code is run?
PLEASE PLEASE!! DON'T JUST GIVE ME AN ANSWER, INSTEAD EXPLAIN ME HOW DO YOU KNOW THE ANSWER IS CORRECT WITHOUT ACTUALLY ENTERING INTO THE COMPUTER. EXPLAIN EACH ONE, I WOULD APPRECIATE THAT.
int a = -32 / 5;
double b = 66 / 32;
char c = 'Q' + 3;
char d = '9' - '6';
double e = 11 / 22.0;
bool f = 22 % 4;
int g = 20 - 4 / (9 + 12);
int h = 7 + 4 * 9 / 11;
int i = 8 + 24 * 3 % 5;
float j = 10.0 + 15 / 2 + 4.3;
Explanation / Answer
1) -6 . reason:when we divide -32/5 we get solution -6 because decimal value is truncated ,as we are using int datatype,negative sign because single negative sign is used.
2) 2 Reason:Direct division
3) T reason:It counts the number in ASCII. Q+3 is T
4)
5) 0.5:Direct division and decimal is evaluated ,because double data type is used
6) 1: because we get remainder here and data type is bool,which is true.
7) 20
8) 10: Reason: First multiplication,then division and finally addition is performed here (rules of precedence:modulus ,multiplication and division happens first,then Addition and finally subtraction from left to right)
9) 10 reason:calculation happen as per rules of precedence
10) 21.3 :Reason:Here datatype is float,so decimal calculation is performed here.Calculation happens as per precedence rules
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.