C++ Pointers & Functions Question:
Download Questions PDF

Output of this program?

#include <iostream>
using namespace std;
int main()
{
int i;
char *arr[] = {"C", "C++", "Java", "VBA"};
char *(*ptr)[4] = &arr;
cout << ++(*ptr)[2];
return 0;
}
a) ava
b) java
c) c++
d) compile time error

Answer:

a) ava

Download C++ Pointers & Functions Interview Questions And Answers PDF

Previous QuestionNext Question
What is the output of this program?

#include <iostream>
using namespace std;
int main()
{
int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
return 0;
}
a) 15 18 21
b) 21 21 21
c) 24 24 24
d) Compile time error
The output of this program?

#include <iostream>
using namespace std;
int main()
{
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << *p;
return 0;
}
a) 4
b) 5
c) 6
d) 7