Chapter 6 Exercise Set 1: CPE PracticeΒΆ
What is the output of the following program?
#include <iostream> using namespace std; int main() { int i = 12; float f = 1000.0; while (i > 0) { i -= 3; f /= 10; } cout << f << endl; return 0; }
0.01
1
0.1
10
What is the output of the following program?
#include <iostream> using namespace std; int main() { int i = 12; float f = -1.0; while (i < 0) { f = f + 5.0 * f / -5; --i; } cout << i << endl; return 0; }
5
12
18
24