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
Related Posts
The output of the two codes shown below is the same.
i. bin((2**16)-1)
ii. ‘{}’.format(bin((2**16)-1))What will be the output of the following Python code?
hex(255), int(‘FF’, 16), 0xFFThe formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
What will be the output of the following Python code?
l=list(‘HELLO’)
p=l[0], l[-1], l[1:3]
‘a={0}, b={1}, c={2}’.format(*p)What will be the output of the following Python code?
l=list(‘HELLO’)
‘first={0[0]}, third={0[2]}’.format(l)The output of the two codes shown below is the same.
i. ‘{0:.2f}’.format(1/3.0)
ii. ‘%.2f’%(1/3.0)What will be the output of the following Python code?
‘%x %d’ %(255, 255)
Join The Discussion