- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Increment Operator (P.59)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int a = 20;
int b = 15;
cout << a-- - --b << endl;
return 0;
}
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Shorthand notation (P.58)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int a = 144;
int b = 12;
int c = 6;
a /= b + c;
cout << a << endl;
return 0;
}
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Type Conversion (P.63)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
float R = 2.0;
cout << 3 / 2 * R * R << endl;
cout << R * R * 3 / 2 << endl;
return 0;
}