Discussion Forum : Pointers
Question -

What is the output of this program?

#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

Options:
A .  ABCDEFGHIJ
B .  AAAAAAAAAA
C .  JJJJJJJJ
D .  none of the mentioned
Answer: Option A


Each time we are assigning 65 + i. In first iteration i = 0 and 65 is assigned. So it will print from A to J.



Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *