LearnFrenzy
Sign in Take a free test
C

C Programming · Topic 5 of 23

Pointers Questions and Concepts

  • 4 exercises
  • 40 questions
  • ~60 min
  • Answers explained

Interview Questions

Pointers · Study material

C Pointers Interview Questions and Answers

1. What is a pointer?

A variable that stores the memory address of another variable. Its type tells the compiler what kind of value is at that address and how far p + 1 moves.

2. What is the difference between *p++, (*p)++ and ++*p?

*p++ reads the value, then moves the pointer to the next element. (*p)++ increments the value p points to and leaves p alone. ++*p also increments the value, but the expression gives the new value.

3. What is a NULL pointer, and why use it?

A pointer that points to no object. It marks "no address yet" or "not found" and can be tested before dereferencing. Dereferencing NULL is undefined behaviour.

4. What are wild and dangling pointers?

A wild pointer was never initialised. A dangling pointer points to memory that was freed or to a local variable whose function has returned. Both lead to undefined behaviour.

5. What is a void pointer?

A generic pointer (void *) that can hold any object address. It cannot be dereferenced or used in arithmetic until it is converted to a typed pointer.

6. Is an array name a pointer?

No. It decays to a pointer to its first element in most expressions, but it is not a variable: you cannot assign to it, and sizeof and & treat it as the whole array.

7. How is call by reference done in C?

C passes everything by value, so you pass the address of a variable and the function changes it through the pointer, as in swap(&a, &b).

8. What is the difference between const int *p and int *const p?

The first is a pointer to a constant int: you cannot change *p, but you can point p elsewhere. The second is a constant pointer: you can change *p, but not p itself.

9. What is a function pointer? Give a use.

A pointer that stores the address of a function, declared like int (*f)(int, int). It is used for callbacks, menus and the comparator of qsort().

10. What is a memory leak?

Memory allocated with malloc() that is never freed, usually because the last pointer to it was overwritten or went out of scope.

11. Why does a function need a pointer to a pointer to change a pointer?

Because the pointer argument is a copy. To make the caller's pointer point somewhere new – for example the head of a linked list – the function needs its address, a T **.

12. Can two pointers be added?

No. You can add an integer to a pointer, subtract two pointers into the same array (the result is a ptrdiff_t element count) and compare them, but adding two addresses has no meaning.

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About C Programming

C programming is the language most computer science courses start with and the foundation of operating systems, embedded devices and compilers. This section helps you learn C properly – data types, operators, control statements, functions, arrays, strings, pointers, structures, memory allocation and files – and then prove it with hundreds of practice questions explained line by line.

Why it matters

  • C teaches how a computer really works: memory, addresses and how data is stored
  • Pointers and memory questions are a favourite in written tests and technical interviews
  • Once you know C, learning C++, Java and Python becomes much easier
  • Embedded systems, operating systems and many companies' coding rounds still use C

Who it is for

  • School students (Class 11–12 computer science) building a strong programming base
  • College students (B.Tech, BCA, MCA, B.Sc CS) preparing for semester exams, lab work and viva
  • Freshers preparing for campus placements, aptitude-cum-coding tests and technical interviews
  • Anyone preparing for GATE CS or government IT exams

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • MCQs that check your understanding of every concept
  • "Predict the output" puzzles – the trickiest part of written tests
  • "Find the error" programs that train you to spot bugs quickly
  • Complete programs with solutions and real output, verified on a compiler

Asked in

  • Campus placements
  • TCS, Infosys, Wipro tests
  • Technical interviews
  • GATE CS
  • University exams
  • Government IT exams

How to use this section

  1. Read the study material of a topic and run the examples yourself.
  2. Practise the four exercises – MCQs, output, errors, programs – and read every explanation.
  3. Test yourself with the timed online test, then revise the topics you got wrong.

Search LearnFrenzy

Esc

Quick links