Programming for Problem Solving (3110003) MCQs

MCQs of Pointers

Showing 11 to 20 out of 25 Questions
11.
What is the output?

void main()
{
    int* pc, c;
    c = 5;
    pc = &c;
    c = 1;
    printf("%d, %d", c,*pc); 
}

(a) 1, 1
(b) 1, 5
(c) 5, 1
(d) Error
Answer:

Option (a)

12.
What is the output?

void main() 
{  
    int a = 5; 
    int *ptr ; 
    ptr = &a; 
    *ptr = *ptr * 3; 
    printf("%d", a); 
}

(a) Some address
(b) 5
(c) 15
(d) Error
Answer:

Option (c)

13.
What is the output?

void main()
{
    int* pc, c;
    c = 5;
    pc = &c;
    *pc = 1;
    printf("%d, %d", c,*pc); 
}

(a) 1, 1
(b) 1, 5
(c) 5, 1
(d) Error
Answer:

Option (a)

14.
What is the output?

void main() 

    int i = 3, *j, k; 
    j = &i; 
    printf("%d\n", i * *j * i + *j); 
}

(a) 30
(b) 27
(c) 9
(d) 3
Answer:

Option (a)

15.
What is an array base address in c language?
(a) Base address is the address of 0th index element
(b) An array b[] base address is &b[0]
(c) An array b[] base address can be printed with printf("%d", b);
(d) All of these
Answer:

Option (d)

16.
What is meaning of the following statement?
int *ptr[20];
(a) Integer array to integer pointers having size 20
(b) Array of integer pointers of size 20
(c) Integer array of size 20 pointing to an integer pointer
(d) None of these
Answer:

Option (b)

17.
What is the output?

void main()
{
    char str[] = "peace";
    char *s = str;
    printf("%s\n", s+3);
}

(a) Peace
(b) eace
(c) ace
(d) ce
Answer:

Option (b)

18.
What is the output?

void main()
{
    int a[3] = {20,30,40};
    printf("%d", *(a+1));
}

(a) 20
(b) 30
(c) 40
(d) Compiler error
Answer:

Option (b)

19.
What is the output?

void main()
{
    int a[4] = {5,6,7,8};
    printf("%d %d", *(a+2), a[1]);
}

(a) 8 6
(b) 7 6
(c) 6 6
(d) Compiler error
Answer:

Option (b)

20.
The declaration
int (*p)[5];
means
(a) p is one dimension array of size 5, of pointers to integers
(b) p is a pointer to a 5 elements integer array
(c) Incorrect declaration
(d) None of these
Answer:

Option (b)

Showing 11 to 20 out of 25 Questions