1. What is the output of the following snippet?
int i = 0, j = i++, k = –i;
if(i > 0)
j++;
else
k++;
if(k == 0)
i++;
else if(k > 0)
k–;
else
k++;
cout << i * j * k;
0
-1
2
1
2. What is the output of the following snippet?
int i = 1, j = i++, k = –i;
if(i > 0) {
j++;
k++;
}
else {
k++;
i++;
}
if(k == 0) {
i++;
j++;
}
else {
if(k > 0)
k–;
else
k++;
i++;
}
cout << i * j * k;
2
4
8
0
3. What is the output of the following snippet?
, double big = 1e15;
double small = 1e-15;
cout << fixed << big + small;
0.0
1000000000000000.000000
1.01e15
1000000000000000.0000000000000001
4. What is the output of the following snippet?
bool yes = !false;
bool no = !yes;
if(!no)
cout << “true”;
else
cout << “false” ;
not
yes
true
false
5. What is the output of the following snippet?
#include <iostream>
using namespace std;
int main() {
int i = 5, j = 0;
while(i > 0) {
i–;
j++;
}
cout << j;
return 0;
}
4
5
2
3
6. What is the output of the following snippet?
#include <iostream>
using namespace std;
int main() {
int i = 3, j = 0;
do {
i–;
j++;
int i = 0, j = i++, k = –i;
if(i > 0)
j++;
else
k++;
if(k == 0)
i++;
else if(k > 0)
k–;
else
k++;
cout << i * j * k;
0
-1
2
1
2. What is the output of the following snippet?
int i = 1, j = i++, k = –i;
if(i > 0) {
j++;
k++;
}
else {
k++;
i++;
}
if(k == 0) {
i++;
j++;
}
else {
if(k > 0)
k–;
else
k++;
i++;
}
cout << i * j * k;
2
4
8
0
3. What is the output of the following snippet?
, double big = 1e15;
double small = 1e-15;
cout << fixed << big + small;
0.0
1000000000000000.000000
1.01e15
1000000000000000.0000000000000001
4. What is the output of the following snippet?
bool yes = !false;
bool no = !yes;
if(!no)
cout << “true”;
else
cout << “false” ;
not
yes
true
false
5. What is the output of the following snippet?
#include <iostream>
using namespace std;
int main() {
int i = 5, j = 0;
while(i > 0) {
i–;
j++;
}
cout << j;
return 0;
}
4
5
2
3
6. What is the output of the following snippet?
#include <iostream>
using namespace std;
int main() {
int i = 3, j = 0;
do {
i–;
j++;