C++ Programming Output Prediction Questions
Question 1
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x == 10) {
cout << "x is 10" << endl;
} else {
cout << "x is not 10" << endl;
return 0;
Answer
x is 10
Question 2
#include <iostream>
using namespace std;
void func(int *p, int *q) {
p = q;
C++ Programming Output Prediction Questions
*p = 2;
int main() {
int a = 1, b = 3;
int *p = &a, *q = &b;
func(p, q);
cout << a << " " << b << endl;
return 0;
Answer
12
Question 3
#include <iostream>
using namespace std;
int main() {
int x = 5;
if (x > 1) {
cout << "x is greater than 1" << endl;
if (x < 10) {
C++ Programming Output Prediction Questions
cout << "x is less than 10" << endl;
} else {
cout << "x is 1 or less" << endl;
return 0;
Answer
x is greater than 1
x is less than 10
Question 4
#include <iostream>
using namespace std;
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
int main() {
C++ Programming Output Prediction Questions
int x = 10, y = 20;
swap(&x, &y);
cout << "x = " << x << ", y = " << y << endl;
return 0;
Answer
x = 20, y = 10
Question 5
#include <iostream>
using namespace std;
void changeValue(int *a) {
*a = 100;
int main() {
int x = 10;
changeValue(&x);
cout << "x = " << x << endl;
return 0;
}
C++ Programming Output Prediction Questions
Answer
x = 100
Question 6
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << "x = " << x << endl;
return 0;
Answer
x = 10
Question 7
#include <iostream>
using namespace std;
int main() {
C++ Programming Output Prediction Questions
int x = 5;
cout << x << " " << x++ << " " << x << endl;
return 0;
Answer
556
Question 8
#include <iostream>
using namespace std;
int main() {
int a = 10, b = 20, c;
c = a + b;
cout << "Sum = " << c << endl;
return 0;
Answer
Sum = 30
C++ Programming Output Prediction Questions
Question 9
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 20, z = 30;
cout << x << " " << y << " " << z << endl;
return 0;
Answer
10 20 30
Question 10
#include <iostream>
using namespace std;
void func(int *p) {
*p = 20;
int main() {
int a = 10;
C++ Programming Output Prediction Questions
func(&a);
cout << "a = " << a << endl;
return 0;
Answer
a = 20
Question 11
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x == 10) {
cout << "x is 10" << endl;
} else {
cout << "x is not 10" << endl;
return 0;
Answer
C++ Programming Output Prediction Questions
x is 10
Question 12
#include <iostream>
using namespace std;
void func(int *p, int *q) {
p = q;
*p = 2;
int main() {
int a = 1, b = 3;
int *p = &a, *q = &b;
func(p, q);
cout << a << " " << b << endl;
return 0;
Answer
12
C++ Programming Output Prediction Questions
Question 13
#include <iostream>
using namespace std;
int main() {
int x = 5;
if (x > 1) {
cout << "x is greater than 1" << endl;
if (x < 10) {
cout << "x is less than 10" << endl;
} else {
cout << "x is 1 or less" << endl;
return 0;
Answer
x is greater than 1
x is less than 10
Question 14
#include <iostream>
C++ Programming Output Prediction Questions
using namespace std;
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
int main() {
int x = 10, y = 20;
swap(&x, &y);
cout << "x = " << x << ", y = " << y << endl;
return 0;
Answer
x = 20, y = 10
Question 15
#include <iostream>
using namespace std;
void changeValue(int *a) {
C++ Programming Output Prediction Questions
*a = 100;
int main() {
int x = 10;
changeValue(&x);
cout << "x = " << x << endl;
return 0;
Answer
x = 100
Question 16
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << "x = " << x << endl;
return 0;
}
C++ Programming Output Prediction Questions
Answer
x = 10
Question 17
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << x << " " << x++ << " " << x << endl;
return 0;
Answer
556
Question 18
#include <iostream>
using namespace std;
int main() {
C++ Programming Output Prediction Questions
int a = 10, b = 20, c;
c = a + b;
cout << "Sum = " << c << endl;
return 0;
Answer
Sum = 30
Question 19
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 20, z = 30;
cout << x << " " << y << " " << z << endl;
return 0;
Answer
10 20 30
C++ Programming Output Prediction Questions
Question 20
#include <iostream>
using namespace std;
void func(int *p) {
*p = 20;
int main() {
int a = 10;
func(&a);
cout << "a = " << a << endl;
return 0;
Answer
a = 20
Question 21
#include <iostream>
using namespace std;
int main() {
C++ Programming Output Prediction Questions
int x = 10;
if (x == 10) {
cout << "x is 10" << endl;
} else {
cout << "x is not 10" << endl;
return 0;
Answer
x is 10
Question 22
#include <iostream>
using namespace std;
void func(int *p, int *q) {
p = q;
*p = 2;
int main() {
int a = 1, b = 3;
C++ Programming Output Prediction Questions
int *p = &a, *q = &b;
func(p, q);
cout << a << " " << b << endl;
return 0;
Answer
12
Question 23
#include <iostream>
using namespace std;
int main() {
int x = 5;
if (x > 1) {
cout << "x is greater than 1" << endl;
if (x < 10) {
cout << "x is less than 10" << endl;
} else {
cout << "x is 1 or less" << endl;
}
C++ Programming Output Prediction Questions
return 0;
Answer
x is greater than 1
x is less than 10
Question 24
#include <iostream>
using namespace std;
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
int main() {
int x = 10, y = 20;
swap(&x, &y);
cout << "x = " << x << ", y = " << y << endl;
return 0;
}
C++ Programming Output Prediction Questions
Answer
x = 20, y = 10
Question 25
#include <iostream>
using namespace std;
void changeValue(int *a) {
*a = 100;
int main() {
int x = 10;
changeValue(&x);
cout << "x = " << x << endl;
return 0;
Answer
x = 100
Question 26
C++ Programming Output Prediction Questions
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << "x = " << x << endl;
return 0;
Answer
x = 10
Question 27
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << x << " " << x++ << " " << x << endl;
return 0;
Answer
C++ Programming Output Prediction Questions
556
Question 28
#include <iostream>
using namespace std;
int main() {
int a = 10, b = 20, c;
c = a + b;
cout << "Sum = " << c << endl;
return 0;
Answer
Sum = 30
Question 29
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 20, z = 30;
C++ Programming Output Prediction Questions
cout << x << " " << y << " " << z << endl;
return 0;
Answer
10 20 30
Question 30
#include <iostream>
using namespace std;
void func(int *p) {
*p = 20;
int main() {
int a = 10;
func(&a);
cout << "a = " << a << endl;
return 0;
Answer
C++ Programming Output Prediction Questions
a = 20
Question 31
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x == 10) {
cout << "x is 10" << endl;
} else {
cout << "x is not 10" << endl;
return 0;
Answer
x is 10
Question 32
#include <iostream>
using namespace std;
C++ Programming Output Prediction Questions
void func(int *p, int *q) {
p = q;
*p = 2;
int main() {
int a = 1, b = 3;
int *p = &a, *q = &b;
func(p, q);
cout << a << " " << b << endl;
return 0;
Answer
12
Question 33
#include <iostream>
using namespace std;
int main() {
int x = 5;
C++ Programming Output Prediction Questions
if (x > 1) {
cout << "x is greater than 1" << endl;
if (x < 10) {
cout << "x is less than 10" << endl;
} else {
cout << "x is 1 or less" << endl;
return 0;
Answer
x is greater than 1
x is less than 10
Question 34
#include <iostream>
using namespace std;
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
C++ Programming Output Prediction Questions
int main() {
int x = 10, y = 20;
swap(&x, &y);
cout << "x = " << x << ", y = " << y << endl;
return 0;
Answer
x = 20, y = 10
Question 35
#include <iostream>
using namespace std;
void changeValue(int *a) {
*a = 100;
int main() {
int x = 10;
changeValue(&x);
C++ Programming Output Prediction Questions
cout << "x = " << x << endl;
return 0;
Answer
x = 100
Question 36
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << "x = " << x << endl;
return 0;
Answer
x = 10
Question 37
C++ Programming Output Prediction Questions
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << x << " " << x++ << " " << x << endl;
return 0;
Answer
556
Question 38
#include <iostream>
using namespace std;
int main() {
int a = 10, b = 20, c;
c = a + b;
cout << "Sum = " << c << endl;
return 0;
}
C++ Programming Output Prediction Questions
Answer
Sum = 30
Question 39
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 20, z = 30;
cout << x << " " << y << " " << z << endl;
return 0;
Answer
10 20 30
Question 40
#include <iostream>
using namespace std;
void func(int *p) {
C++ Programming Output Prediction Questions
*p = 20;
int main() {
int a = 10;
func(&a);
cout << "a = " << a << endl;
return 0;
Answer
a = 20
Question 41
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x == 10) {
cout << "x is 10" << endl;
} else {
cout << "x is not 10" << endl;
C++ Programming Output Prediction Questions
return 0;
Answer
x is 10
Question 42
#include <iostream>
using namespace std;
void func(int *p, int *q) {
p = q;
*p = 2;
int main() {
int a = 1, b = 3;
int *p = &a, *q = &b;
func(p, q);
cout << a << " " << b << endl;
return 0;
}
C++ Programming Output Prediction Questions
Answer
12
Question 43
#include <iostream>
using namespace std;
int main() {
int x = 5;
if (x > 1) {
cout << "x is greater than 1" << endl;
if (x < 10) {
cout << "x is less than 10" << endl;
} else {
cout << "x is 1 or less" << endl;
return 0;
Answer
x is greater than 1
x is less than 10
C++ Programming Output Prediction Questions
Question 44
#include <iostream>
using namespace std;
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
int main() {
int x = 10, y = 20;
swap(&x, &y);
cout << "x = " << x << ", y = " << y << endl;
return 0;
Answer
x = 20, y = 10
Question 45
#include <iostream>
using namespace std;
C++ Programming Output Prediction Questions
void changeValue(int *a) {
*a = 100;
int main() {
int x = 10;
changeValue(&x);
cout << "x = " << x << endl;
return 0;
Answer
x = 100
Question 46
#include <iostream>
using namespace std;
int main() {
int x = 10;
cout << "x = " << x << endl;
return 0;
C++ Programming Output Prediction Questions
Answer
x = 10
Question 47
#include <iostream>
using namespace std;
int main() {
int x = 5;
cout << x << " " << x++ << " " << x << endl;
return 0;
Answer
556
Question 48
#include <iostream>
using namespace std;
C++ Programming Output Prediction Questions
int main() {
int a = 10, b = 20, c;
c = a + b;
cout << "Sum = " << c << endl;
return 0;
Answer
Sum = 30
Question 49
#include <iostream>
using namespace std;
int main() {
int x = 10, y = 20, z = 30;
cout << x << " " << y << " " << z << endl;
return 0;
Answer
10 20 30
C++ Programming Output Prediction Questions
Question 50
#include <iostream>
using namespace std;
void func(int *p) {
*p = 20;
int main() {
int a = 10;
func(&a);
cout << "a = " << a << endl;
return 0;
Answer
a = 20