C++ Institute CPA-21-02 Exam - Topic 2 Question 42 Discussion
What happens when you attempt to compile and run the following code?#include using namespace std;int main(){int *i;i = new int;*i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4;cout
C) It prints: 2
A) It prints: 0
B) It prints: 1
D) It prints: 0.5
C++ Institute CPA-21-02 Exam - Topic 2 Question 42 Discussion
Actual exam question for
C++ Institute's
CPA-21-02 exam
I remember something about integer division in C++. If I recall correctly, 1.0 / 2 would be treated as a double, but the result gets assigned to an int pointer.
Latia
8 months agoAltha
9 months agoAlana
9 months agoJamie
9 months agoBeckie
9 months agoMatilda
9 months agoJeffrey
10 months agoCory
10 months agoAlaine
10 months agoPhung
10 months agoOretha
10 months agoColby
11 months agoJesusa
11 months agoShantell
11 months agoKerrie
12 months agoBuddy
1 year agoMarylyn
1 year agoPearly
1 year agoLorriane
1 year agoWillodean
1 year agoDortha
1 year agoLorriane
1 year agoDortha
1 year ago