- (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.74)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int a = 10;
int b = 20;
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.73)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int a = 36;
int b = 12;
int c = 24;
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.78)
#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;
}