Question 1
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
bool ints = sizeof(long) >= sizeof(int) && sizeof(int) >= sizeof(short);
bool floats = sizeof(double) < sizeof(float);
bool chars = sizeof(char) == 1;
int v = ints && floats && chars;
cout << v << endl;
return 0;
}
true
false
0
1
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
int t[4] = { 8, 4, 2, 1 };
, int *p1 = t + 2, *p2 = p1 - 1;
p1++;
cout << *p1 - t[p1 - p2] << endl;
return 0;
}
-2
1
2
-1
Question 3
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int fun(int p) {
++p;
return p++;
}
int main(void) {
int a = 1, b;
b = fun(a);
cout << a + b << endl;
return 0;
}
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
bool ints = sizeof(long) >= sizeof(int) && sizeof(int) >= sizeof(short);
bool floats = sizeof(double) < sizeof(float);
bool chars = sizeof(char) == 1;
int v = ints && floats && chars;
cout << v << endl;
return 0;
}
true
false
0
1
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int main(void) {
int t[4] = { 8, 4, 2, 1 };
, int *p1 = t + 2, *p2 = p1 - 1;
p1++;
cout << *p1 - t[p1 - p2] << endl;
return 0;
}
-2
1
2
-1
Question 3
pts
What is the output of the following program?
#include <iostream>
using namespace std;
int fun(int p) {
++p;
return p++;
}
int main(void) {
int a = 1, b;
b = fun(a);
cout << a + b << endl;
return 0;
}