- 2.3k
- 2
- 22
- 34
- 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?
- 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?
- 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?
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?
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?
- 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?