Machine-translated by Google. Questions are authored in English.
Top

Pointers Questions and Answers

11.

In C, which of the following is TRUE about arrays and pointers ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

The true statement is that array[i] is equivalent to *(array + i).

C defines subscripting in terms of pointer arithmetic: in an expression the array name becomes a pointer to its first element, adding i moves the pointer i elements along, and the dereference reads that element. The two forms are interchangeable by the language definition (which is also why the odd form i[array] compiles).

sizeof(array) gives the size of the whole array, for example 40 for ten 4-byte ints, not the size of a pointer; they coincide only for an array parameter, which is really a pointer. An array name is not a modifiable lvalue, so array++ is an error. Since C is true, 'None of these' is wrong.

Please log in or register to report this question.

12.

What is the output of the following pseudocode?

int arr[] = {1, 2, 3, 4, 5}
int *ptr = arr + 2
print(*ptr + *(ptr + 1))

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

The output is 7.

The array holds 1, 2, 3, 4, 5 at indices 0 to 4. arr + 2 points to index 2, so *ptr is 3. ptr + 1 points to index 3, so *(ptr + 1) is 4. The sum is 3 + 4 = 7.

Pointer arithmetic moves by whole elements, not bytes, so arr + 2 is the third element. 5 is the sum of indices 1 and 2 (2 + 3), a slip of taking arr + 2 as the second element. 9 is 4 + 5, a slip of one position too far, and 3 is the first value alone.

Please log in or register to report this question.

13.

If int *p points to arr[2], then (p+1) points to

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: B

p + 1 points to arr[3].

In pointer arithmetic, adding 1 to a pointer moves it forward by one element of the type it points to, not by one byte. If p holds the address of arr[2], then p + 1 holds the address of the next int, arr[3]; the compiler scales the 1 by sizeof(int) automatically.

arr[1] would be p - 1. arr[2]+1 describes adding 1 to the value stored in arr[2], not moving the pointer, and the result can be determined exactly from the rules of pointer arithmetic.

Please log in or register to report this question.

14.

What is the output of the following program ?

#include<stdio.h>
void f(int *p, int *q) {
    p=q;
    *p=2;
}
int i=0, j=1;
int main(void){
    f(&i, &j);
    printf("%d %d\n", i, j);
    }

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: D

The program prints 0 2.

C passes arguments by value, so p and q are local copies of the addresses &i and &j. Walk through f:

  1. p=q; changes only the local copy p, which now holds &j. The variable i is untouched.
  2. *p=2; writes 2 through p, that is into j.

Back in main, i is still 0 and j is now 2, so printf prints 0 2. '2 1' is what you would get if *p=2 still wrote to i; '2 2' assumes p=q changed main's pointer; '0 1' ignores the write through p altogether.

Please log in or register to report this question.

15.

What is the output of the following program ?

#include <stdio.h>
int f (int *a, int n)
{
if(n<=0) return 0;
else if (*a%2 = = 0) return *a + f(a+1, n-1);
else return *a - f(a+1, n-1);
}
int main(void)
{
int a[] = {12, 7, 13, 4, 11, 6};
printf("%d", f(a,6));
return 0;
}

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

The program prints 15.

f adds an even element and subtracts the result of the rest after an odd element. Work from the end of the array {12, 7, 13, 4, 11, 6}:

\[ \begin{aligned} f(\{6\}) &= 6 + 0 = 6 \\ f(\{11,6\}) &= 11 - 6 = 5 \\ f(\{4,\ldots\}) &= 4 + 5 = 9 \\ f(\{13,\ldots\}) &= 13 - 9 = 4 \\ f(\{7,\ldots\}) &= 7 - 4 = 3 \\ f(\{12,\ldots\}) &= 12 + 3 = 15 \end{aligned} \]

The trap is reading it as an alternating sum of the elements; the subtraction applies to the whole remaining result, not to the next element alone. 5 is the value at the 11 step, and -9 and 19 come from sign slips.

Please log in or register to report this question.

Direction for [ Question No: 16 To 16 ] :

Directions : The following items consist of two statements, one labelled the "Assertion (A)" and the other labelled the "Reason (R)". You are to examine these two statements carefully and decide if the Assertion (A) and the Reason (R) are individually true and if so, whether the Reason is a correct explanation of the Assertion. Select your answers to these items using the codes given below and mark your answer accordingly.

16.

Assertion (A) : In 'FORTRAN' pointers are provided.

Reason (R) : Pointers help to work with actual physical addresses.

Exam Year(s)

UGC NET - 2012,

Answer: D

The assertion is false and the reason is true (option D). Standard FORTRAN does not provide pointers, so the assertion is wrong, while C and Pascal do provide them.

The reason is a true statement about what pointers do, that they let a program work with actual memory addresses. Since the assertion is false, options A, B and C, which accept it, are wrong.

Please log in or register to report this question.

17.

What does the following declaration mean ? int (*ptr) [10];

Exam Year(s)

UGC NET - 2013,

Answer: B

The declaration int (*ptr)[10]; means that ptr is a pointer to an array of 10 integers. The parentheses bind the star to ptr first, so ptr is a pointer, and the [10] then describes the thing it points to.

An array of 10 pointers to integers would be written int *ptr[10], without the parentheses. A plain array of 10 integers would be int ptr[10]. Since the declaration is a valid one with a clear meaning, 'none of the above' is wrong.

Please log in or register to report this question.

Direction for [ Question No: 18 To 18 ] :

Directions : The following items consist of two statements, one labelled the "Assertion" (A) and other labelled the "Reason" (R). You are to examine these two statements carefully and decide if the Assertion (A) and the Reason (R) are individually true and if so, whether the Reason is a correct explanation of the Assertion. Select your answers to these items using the codes given below and mark your answer accordingly.

18.

Assertion (A) : char str[] = "paper"
'str' acts as a constant pointer to a string.

Reason (R) : *P = "Paper"
"P" acts as a pointer to a constant string.

Exam Year(s)

UGC NET - 2013,

Answer: B

Both statements are true but the reason does not explain the assertion, which is option (B). In char str[] = "paper" the name str is the address of the first element of the array and cannot be changed, so it behaves as a constant pointer to the string. In the reason, P is a pointer that is made to point at a string constant, so it is a pointer to a constant string. The two describe different declarations, so one does not explain the other, which rules out (A), and neither statement is false, which rules out (C) and (D).

Please log in or register to report this question.

19.

Trace the error :

void main( )\n{\n    int *b, &a;\n    *b = 20\n    printf("%d, %d", a, *b)\n}

Exam Year(s)

UGC NET - 2013,

Answer: C

The program has a syntax error, which is option (C). The statement *b = 20 is not ended by a semicolon, and so is the printf statement, and the declaration of a reference a with the operator & has no place in C and would in any case need an initialiser.

A logical error or a semantic error is one that a compiler accepts, whereas these are mistakes of form that the compiler rejects. Also, b is used without being given an address, but the compiler stops on the syntax error first. So (A), (B) and (D) are wrong.

Please log in or register to report this question.

Answer: D

The first declaration, int *f( ), declares a function returning a pointer to an integer, and the second, int (*f)( ), declares a pointer to a function returning an integer. The parentheses around *f bind the star to f, making it a pointer, while without them the function call operator binds first.

The two are not identical, and both are valid declarations, so the options saying that the second is wrong, or that both declare a pointer to a function, are wrong.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Pointers Questions and Answers || Pointers MCQ Questions and Answers || Pointers GK Questions and Answers || Pointers GK MCQ Questions || Pointers Multiple Choice Questions and Answers || Pointers GK || GK on Pointers || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming