Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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;
}

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;
}
a) ava
b) java
c) c++
d) compile time error

Answer: a
Explanation: In this program we are moving the pointer from first position to second position and printing the remaining value.
Output:
ava

Join The Discussion