Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Post Closed as "Duplicate" by Mad Physicist, anatolyg, Community Bot
edited tags
Link
Jim Lewis
  • 45.5k
  • 7
  • 86
  • 97
  1. What is the output of the following code fragment? [2 marks]

int arr[5] = {1, 2, 3};
int *pl*p1, *p2;
plp1 = arr;
p2 = &arr[3];
printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

  1. What is the output of the following code fragment? [2 marks]

int arr[5] = {1, 2, 3};
int *pl, *p2;
pl = arr;
p2 = &arr[3];
printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

  1. What is the output of the following code fragment?

int arr[5] = {1, 2, 3};
int *p1, *p2;
p1 = arr;
p2 = &arr[3];
printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

added 20 characters in body
Source Link
Joseph Young
  • 2.8k
  • 15
  • 23
  1. What is the output of the following code fragment? [2 marks]

    int arr[5] = {1, 2, 3}; int *pl, *p2; pl = arr; p2 = &arr[3]; printf("%d\n", (*p1)++ + --(*p2));

    What is the output of the following code fragment? [2 marks]

int arr[5] = {1, 2, 3};
int *pl, *p2;
pl = arr;
p2 = &arr[3];
printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

  1. What is the output of the following code fragment? [2 marks]

    int arr[5] = {1, 2, 3}; int *pl, *p2; pl = arr; p2 = &arr[3]; printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

  1. What is the output of the following code fragment? [2 marks]

int arr[5] = {1, 2, 3};
int *pl, *p2;
pl = arr;
p2 = &arr[3];
printf("%d\n", (*p1)++ + --(*p2));

From my understanding, The first line initialises an array of 5 memory spaces and only fills positions 0,1 and 2. Then in the 3rd and 4th line, p1 points to the array position 0 and p2 points to array position 3 which is empty. So in line 5 when the question tries to print (*p1)++ + --(*p2), what will it print since p2 points to memory not containing any values?

Source Link
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /