Reason About C Pointer and Array Declarations

Quick Overview

Explain C declarations for arrays of integer pointers and pointers to integer arrays, including how parentheses alter meaning. Cover expression types, indexing, array decay, pointer-arithmetic bounds, undefined dereferences, const qualifiers, multidimensional arrays, and safe function parameters.

Reason About C Pointer and Array Declarations

Company: Cisco

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: easy

Interview Round: Technical Screen

Explain the following C declarations and expressions. Assume `int` objects and ordinary pointer arithmetic. 1. Declare an array of pointers to `int`. 2. Declare a pointer to an array of `N` integers. 3. For each declaration, explain the types of `p`, `*p`, and an indexed expression. 4. Explain what `*(ptr + 3)` means and when it is defined. 5. Show how parentheses change the meaning of `int *p[N]` and `int (*p)[N]`. ### Clarifying Questions to Ask - Is `N` a compile-time constant, a variable-length array bound, or a macro? - What object does the pointer point into? - Are qualifiers such as `const` relevant? ### What a Strong Answer Covers - Reading declarators from the identifier outward - Array-to-pointer decay and its exceptions - Pointer-arithmetic scaling by the pointed-to type - Bounds, one-past pointers, and undefined dereference behavior - A concrete use for each declaration ### Follow-up Questions - Contrast `const int *p` with `int *const p`. - Explain why a two-dimensional array is not an `int **`. - Pass a pointer to an array into a function safely.

Quick Answer: Explain C declarations for arrays of integer pointers and pointers to integer arrays, including how parentheses alter meaning. Cover expression types, indexing, array decay, pointer-arithmetic bounds, undefined dereferences, const qualifiers, multidimensional arrays, and safe function parameters.

|Home/Software Engineering Fundamentals/Cisco
Cisco logo
Cisco
Jul 16, 2026, 12:00 AM
easySoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
1
0

Explain the following C declarations and expressions. Assume int objects and ordinary pointer arithmetic.

  1. Declare an array of pointers to int .
  2. Declare a pointer to an array of N integers.
  3. For each declaration, explain the types of p , *p , and an indexed expression.
  4. Explain what *(ptr + 3) means and when it is defined.
  5. Show how parentheses change the meaning of int *p[N] and int (*p)[N] .

Clarifying Questions to Ask Guidance

  • Is N a compile-time constant, a variable-length array bound, or a macro?
  • What object does the pointer point into?
  • Are qualifiers such as const relevant?

What a Strong Answer Covers Guidance

  • Reading declarators from the identifier outward
  • Array-to-pointer decay and its exceptions
  • Pointer-arithmetic scaling by the pointed-to type
  • Bounds, one-past pointers, and undefined dereference behavior
  • A concrete use for each declaration

Follow-up Questions Guidance

  • Contrast const int *p with int *const p .
  • Explain why a two-dimensional array is not an int ** .
  • Pass a pointer to an array into a function safely.
Loading comments...