Question 1
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
int *t[2] = { new int[2], new int[2] };
for(int i = 0; i < 4; i++)
t[i % 2][i / 2] = i;
cout << t[0][1] + t[1][0] << endl;
delete [] t[0];
delete [] t[1];
return 0;
}
2
4
1
3
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
, int i = 2, j = 3;
float a = 2, b = 3;
cout << float(j) / (float)i << " " << (int)b / int(a) << endl;
return 0;
}
11
1 1.5
1.5 1
1.5 1.5
Question 3
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
double d = 987654321.123456789;
float f = d;
int i = d == f;
cout << i << endl;
return 0;
}
0.0
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
int *t[2] = { new int[2], new int[2] };
for(int i = 0; i < 4; i++)
t[i % 2][i / 2] = i;
cout << t[0][1] + t[1][0] << endl;
delete [] t[0];
delete [] t[1];
return 0;
}
2
4
1
3
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
, int i = 2, j = 3;
float a = 2, b = 3;
cout << float(j) / (float)i << " " << (int)b / int(a) << endl;
return 0;
}
11
1 1.5
1.5 1
1.5 1.5
Question 3
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
double d = 987654321.123456789;
float f = d;
int i = d == f;
cout << i << endl;
return 0;
}
0.0