0% found this document useful (0 votes)
25 views8 pages

MCQ P33

C++ questions

Uploaded by

aadijain0095
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

MCQ P33

C++ questions

Uploaded by

aadijain0095
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

MCQ ON C++

Q.1. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

int n ;

for (n = 5; n < 0; n--)

cout << n;

if (n == 3)

break;

return 0;

2. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

int a = 10;

if (a = 15)

time;

cout << a;

if (n == 3)

goto time;
}

break;

return 0;

3. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main() {

int n = 15;

for (; ;)

cout << n;

return 0;

4. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int fun(int x = 0, int y = 0, int z)

return (x + y + z);

int main()

cout << fun(10);

return 0;

5. What will be the output of the following C++ code?


#include <iostream>using namespace std;

int array1[] = {1200, 200, 2300, 1230, 1543};

int array2[] = {12, 14, 16, 18, 20};

int temp, result = 0;

int main()

for (temp = 0; temp < 5; temp++)

result += array1[temp];

for (temp = 0; temp < 4; temp++){

result += array2[temp];

cout << result;

return 0;

6. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

int array[] = {0, 2, 4, 6, 7, 5, 3};

int n, result = 0;

for (n = 0; n < 8; n++){

result += array[n];

}
cout << result;

return 0;

7. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main() {

int a = 5, b = 10, c = 15;

int arr[3] = {&a, &b, &c};

cout << *arr[*arr[1] - 0];

return 0;

8. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main() {

char str[5] = "ABC";

cout << str [4];

cout << str;

return 0;

9. What will be the output of the following C++ code?

#include <iostream>using namespace std;


int main() {

char array[] = [10, 20, 30];

cout << -2 [array];

return 0;

10. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

int a = 5, b = 10, c = 15;

int *arr[] = {&a, &b, &c};

cout << arr[1];

return 0;

11. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

char arr[20];

int i;

for (i = 0; i < 10; i++)

*(arr + i) = 65 + i;

*(arr + i) = 0;

cout << arr;

return 0;
}

12. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main() {

char *ptr;

char str[] = 'abcdefg';

ptr = str;

ptr += 5;

cout << ptr;

return 0;

13. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()

{ int i;

const char *arr[] = {"c", "c++", "java", "VBA"};

const char *(*ptr)[4] = &arr;

cout << ++(*ptr)[2];

return 0;

14. What will be the output of the following C++ code?

#include <iostream>using namespace std;

int main()
{

int numbers[5];

int *p;

p = numbers; *p = 10;

p++; *p = 20;

p = numbers[2]; *p = 30;

p = numbers + 3; *p = 40;

p = numbers; *(p + 4) = 50;

for (int n = 0; n < 5; n++){

cout << numbers[n] << ",";

return 0;

15. What will be the output of the following C++ code?

#include <iostream> using namespace std;

int main()

int arr[] = {4, 5, 6, 7};

int *p = (arr + 1);

cout << *arr + 9;

return 0;

ANSWER SHEET:
1. NO OUTPUT
2. ERROR
3. INFINITE
4. ERROR
5. 6473
6. 27
7. ERROR
8. ABC
9. ERROR
10. ADDRESS OF 10
11. ABCDEFJHIJ
12. ERROR
13. Ava
14. ERROR
15. 13
===============================****================================================
=

You might also like