Problem:
Given the following declarations, what result is stored in each of
the listed assignment statements?
int iResult, num1 = 25, num2 = 40, num3 = 17, num4 = 5;
double fResult, val1 = 17.0, val2 = 12.78;
a. iResult = num1 / num4;
b. fResult = num1 / num4;
c. iResult = num3 / num4;
d. fResult = num3 / num4;
e. fResult = val1 / num4;
f. fResult = val1 / val2;
g. iResult = num1 / num2;
h. fResult = (double) num1 / num2;
i. fResult = num1 / (double) num2;
j. fResult = (double) (num1 / num2);
k. iResult = (int) (val1 / num4);
l. fResult = (int) (val1 / num4);
m. fResult = (int) ((double) num1 / num2);
n. iResult = num3 % num4;
o. iResult = num2 % num3;
p. iResult = num3 % num2;
q. iResult = num2 % num4;
the listed assignment statements?
int iResult, num1 = 25, num2 = 40, num3 = 17, num4 = 5;
double fResult, val1 = 17.0, val2 = 12.78;
a. iResult = num1 / num4;
b. fResult = num1 / num4;
c. iResult = num3 / num4;
d. fResult = num3 / num4;
e. fResult = val1 / num4;
f. fResult = val1 / val2;
g. iResult = num1 / num2;
h. fResult = (double) num1 / num2;
i. fResult = num1 / (double) num2;
j. fResult = (double) (num1 / num2);
k. iResult = (int) (val1 / num4);
l. fResult = (int) (val1 / num4);
m. fResult = (int) ((double) num1 / num2);
n. iResult = num3 % num4;
o. iResult = num2 % num3;
p. iResult = num3 % num2;
q. iResult = num2 % num4;
Output:
Not Applicable
Solution:
a. iResult = num1 / num4; iResult is assigned 5 b. fResult = num1 / num4; fResult is assigned 5.0 c. iResult = num3 / num4; iResult is assigned 3 d. fResult = num3 / num4; fResult is assigned 3.0 e. fResult = val1 / num4; fResult is assigned 3.4 f. fResult = val1 / val2; fResult is assigned 1.3302034... g. iResult = num1 / num2; iResult is assigned 0 h. fResult = (double) num1 / num2; fResult is assigned 0.625 i. fResult = num1 / (double) num2; fResult is assigned 0.625 j. fResult = (double) (num1 / num2); fResult is assigned 0.0 k. iResult = (int) (val1 / num4); iResult is assigned 3 l. fResult = (int) (val1 / num4); fResult is assigned 3.0 m. fResult = (int) ((double) num1 / num2); fResult is assigned 0.0 n. iResult = num3 % num4; iResult is assigned 2 o. iResult = num 2 % num3; iResult is assigned 6 p. iResult = num3 % num2; iResult is assigned 17 q. iResult = num2 % num4;
No comments :
Post a Comment