C Programming 8

COEP
Lets Crack Online Exam

IT Interview Exam Questions: C Programming 8 (IT Interview Exam Question, IT Campus Placement)

Subject: C Programming 8

Part 8: List for questions and answers of C Language

 

Q1. Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0)?

a) int *ptr = &a;

b) int *ptr = &a – &a;

c) int *ptr = a – a;

d) All of the mentioned

 

Q2. Which is an indirection operator among the following?

a) &

b) *

c) ->

d) .

 

Q3. Which of the following declaration throw run-time error?

a) int **c = &c;

b) int **c = &*c;

c) int **c = **c;

d) None of the mentioned

 

Q4. How many number of pointer (*) does C have against a pointer variable declaration?

a) 7

b) 127

c) 255

d) No limits

 

Q5. Which of the following are correct syntaxes to send an array as a parameter to function:

a) func(&array);

b) func(array);

c) func(*array);

d) func(array[size]);

 

Q6. Given float *pf; int *pi; Which of the following is true?

a) sizeof(pf) > sizeof(pi)

b) sizeof(pi) less than sizeof(pf)

c) sizeof(pf) == sizeof(pi)

d) None of these above 

 

Q7. Size of void pointer is

a) 1 byte

b) 2 byte

c) 4 byte

d) 8 byte

 

Q8. What is wild pointer in c

a) a pointer which we need to write in future

b) a pointer which has bad naming convention

c) a pointer which has no limit

d) a point which has not initialized

 

Q9. What is dangling pointer in c

a) if pointer is pointing to a memory location from where variable has been deleted

b) if pointer is assigned to more than one variable

c) if pointer is not defined properly

d) none of above

 

Q10. What is (void*)0?

a) Representation of NULL pointer

b) Representation of void pointer

c) Error

d) None of above

 

Q11. In which header file is the NULL macro defined?

a) stdio.h

b) stddef.h

c) stdio.h and stddef.h

d) math.h

 

Q12. How many bytes are occupied by near, far and huge pointers (DOS)?

a) near=2 far=4 huge=4

b) near=4 far=8 huge=8

c) near=2 far=4 huge=8

d) near=4 far=4 huge=8 

 

Q13. If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?

a) .

b) &

c) *

d) ->

 

Q14. What would be the equivalent pointer expression for referring the array element  

 a[i][j][k][l] 

a) ((((a+i)+j)+k)+l)

b) *(*(*(*(a+i)+j)+k)+l)

c) (((a+i)+j)+k+l)

d) ((a+i)+j+k+l)

 

Q15. A pointer is

a) A keyword used to create variables

b) A variable that stores address of an instruction

c) A variable that stores address of other variable

d) All of the above

 

Q16. Comment on the following pointer declaration? int *ptr, p;

a) ptr is a pointer to integer, p is not

b) ptr and p, both are pointers to integer

c) ptr is a pointer to integer, p may or may not be

d) ptr and p both are not pointers to integer

 

Q17. Comment on the following? const int *ptr;

a) You cannot change the value pointed by ptr

b) You cannot change the pointer ptr itself

c) Both (a) and (b)

d) You can change the pointer as well as the value pointed by it

 

Q18. Comment on the output of this C code?

    #include <stdio.h>

    int main()

    {

        int a = 10;

        int **c -= &&a;

    }

a) You cannot apply any arithmetic operand to a pointer

b) We don’t have address of an address operator

c) Both (a) and (b)

d) None of the mentioned 

 

Q19. What is the output of this C code? void main()

#include <stdio.h>

    void main()

    {

        int k = 5;

        int *p = &k;

        int **m  = &p;

        **m = 6;

         printf(“%d\n”, k);

    }

a) 5

b) Compile time error

c) 6

d) Junk

 

Q20. What is the output of this C code? 

#include <stdio.h>

    void main()

    {

        int a[3] = {1, 2, 3};

        int *p = a;

        int **r = &p;

        printf(“%p %p”, *r, a);

    }

a) Different address is printed

b) 1 2

c) Same address is printed

d) 2 1 

 

Part 8: List for questions and answers of C Language

 

Q1. Answer: a

 

Q2. Answer: b

 

Q3. Answer: d

 

Q4. Answer: d

 

Q5. Answer: b

 

Q6. Answer: c

 

Q7. Answer: b

 

Q8. Answer: d

 

Q9. Answer: a

 

Q10. Answer: a

 

Q11. Answer: c

 

Q12. Answer: a

 

Q13. Answer: d

 

Q14. Answer: b

 

Q15. Answer: c

 

Q16. Answer: a

 

Q17. Answer: a

 

Q18. Answer: b

 

Q19. Answer: c

 

Q20. Answer: c