Placement Prep

10 C Programming Aptitude Questions with Answers

Ten C programming aptitude questions covering array out-of-bounds, pointer declarations, operator evaluation, and linkage types, with worked answers.

By FACE Prep Team 6 min read
c-programming technical-interview aptitude arrays-pointers placement-prep campus-placement

C programming aptitude questions appear in first-round technical tests at service companies because they test memory awareness, not just syntax recall.

Why C aptitude questions appear in placement technical rounds

Technical screening at Indian service companies combines aptitude, verbal, and technical MCQs. The C questions in the technical section test a specific skill: can you predict what the machine will actually do, given code that looks straightforward but hides a memory or evaluation trap?

The ten questions in this article cover array out-of-bounds behavior, pointer-to-array declarations, pre/post increment evaluation order, the modulo function for floating-point numbers, linkage types, and valid identifier characters. Each category maps to a recurring concept in AMCAT and CoCubes technical modules. Recognising the pattern is faster than memorising every variant individually.

For a broader set of C output-prediction problems, the FACE Prep C coding questions set builds directly on the pointer and array concepts covered here.

Arrays: out-of-bounds, base address, and parameter behavior

Four of the ten questions are about arrays. They cover three ideas: what happens past the end of an array, what gets passed when an array goes into a function, and how arr differs from &arr.

Q1: Out-of-bounds array access

  • Question: What will happen if a C program assigns a value to an array element whose subscript exceeds the declared size?
    • A. The element is set to 0.
    • B. The compiler reports an error.
    • C. The program may crash if important data gets overwritten.
    • D. The array grows automatically.
  • Answer: C
  • Explanation: C performs no runtime bounds checking. Writing past the end of an array overwrites whatever occupies the adjacent memory, which could be a return address, another variable, or a function pointer. The result is undefined behavior. Some compilers can detect this at runtime with address sanitizer flags, but the language standard provides no protection.

Q2: Passing an array to a function

  • Question: In C, if you pass an array as an argument to a function, what actually gets passed?
    • A. Values of all elements
    • B. First element of the array
    • C. Base address of the array
    • D. Address of the last element
  • Answer: C
  • Explanation: Arrays in C decay to a pointer to their first element when passed to a function. The function receives the base address, not a copy of the data. Changes the function makes to array elements are visible to the caller.

Q3: Array parameter declaration variants

  • Question: Is there any difference between these two function declarations?
    int fun(int arr[]);
    int fun(int arr[2]);
    • A. Yes
    • B. No
  • Answer: B
  • Explanation: Both declare the same function. The size inside the brackets of an array function parameter is ignored by the compiler. The parameter decays to int* in either case.

Q4: arr versus &arr

  • Question: Are arr and &arr the same for an array of 10 integers?
    • A. Yes
    • B. No
  • Answer: B
  • Explanation: Both expressions evaluate to the same numeric address (the start of the array block), but their types are different. arr decays to int*, a pointer to the first integer. &arr has type int(*)[10], a pointer to the whole 10-element array. Pointer arithmetic on each moves by a different step size: arr + 1 advances by sizeof(int) bytes; &arr + 1 advances by sizeof(int) * 10 bytes.

Pointer declarations and operator evaluation order

These two questions test whether you can read a C declaration correctly and trace evaluation order when pre/post increment operators appear in the same statement.

Q5: Pointer-to-array declaration

  • Question: What does int (*ptr)[10] declare?
    • A. An array of pointers to 10 integers
    • B. A pointer to an array of 10 integers
    • C. An array of 10 integers
    • D. A generic pointer to an array
  • Answer: B
  • Explanation: Parentheses force *ptr to bind first: ptr is a pointer. What it points to is int[10], an array of 10 integers. Compare with int *ptr[10], where no parentheses are used, so ptr[10] binds first, producing an array of 10 integer pointers.

Q6: Pre/post increment with array indexing

This question is a common source of wrong answers because candidates try to evaluate the whole expression at once. Trace each statement in order.

  • Question: What is the output of this program?
    int a[5] = {5, 1, 15, 20, 25};
    int i, j, m;
    i = ++a[1];
    j = a[1]++;
    m = a[i++];
    printf("%d, %d, %d", i, j, m);
    • A. 2, 1, 15
    • B. 1, 2, 5
    • C. 3, 2, 15
    • D. 2, 3, 20
  • Answer: C
  • Step-by-step:
    • Step 1: Array initialised as a[0]=5, a[1]=1, a[2]=15, a[3]=20, a[4]=25.
    • Step 2: i = ++a[1] is a pre-increment. a[1] becomes 2, then i = 2. State: i=2, a[1]=2.
    • Step 3: j = a[1]++ is a post-increment. j receives the current value of a[1], which is 2, then a[1] becomes 3. State: j=2, a[1]=3.
    • Step 4: m = a[i++]. i is currently 2, so m = a[2] = 15. Then i increments to 3. State: m=15, i=3.
    • Step 5: printf prints i=3, j=2, m=15. Output: 3, 2, 15.

Standard library, linkage types, and C naming rules

The remaining four questions cover the correct function for floating-point remainder, the three linkage categories in C, valid identifier characters, and the meaning of the extern keyword on a function declaration.

Q7: Floating-point modulus

  • Question: Which statement correctly computes the remainder after dividing 3.14 by 2.1?
    • A. rem = 3.14 % 2.1;
    • B. rem = modf(3.14, 2.1);
    • C. rem = fmod(3.14, 2.1);
    • D. Remainder cannot be obtained in floating-point division.
  • Answer: C
  • Explanation: The % operator in C is defined only for integer operands. For floating-point modulus, the C standard library provides fmod(x, y), which computes the IEEE remainder of x divided by y. modf does something different: it splits a floating-point number into its integer and fractional parts.

Q8: Types of linkage in C

  • Question: Which option correctly lists all linkage types in C?
    • A. Internal and external
    • B. External, internal, and none
    • C. External and none
    • D. Internal only
  • Answer: B
  • Explanation: Per the C storage duration and linkage specification, C defines three linkage categories:
    • External linkage: global non-static variables and functions, visible across all translation units in the program.
    • Internal linkage: static variables and functions with file scope, visible only within the same translation unit.
    • No linkage: local variables inside a function block, visible only within that block.

Q9: Valid characters in C identifiers

  • Question: Which special character is allowed in a C variable name?
    • A. * (asterisk)
    • B. | (pipeline)
    • C. - (hyphen)
    • D. _ (the underline character)
  • Answer: D
  • Explanation: C identifiers may contain letters (A-Z, a-z), digits (0-9), and the _ character. They cannot start with a digit. No other special characters are valid. Hyphens, asterisks, and pipes all have syntactic meaning in C expressions and cannot appear inside identifiers.

Q10: extern versus file-scope function declaration

  • Question: What is the difference between these two declarations?
    extern int fun();
    int fun();
    • A. Both are identical.
    • B. No functional difference; extern int fun() signals the function is defined in another file.
    • C. int fun() is overridden by extern int fun().
    • D. None of these.
  • Answer: B
  • Explanation: int fun() at file scope declares that fun is defined in the current translation unit. extern int fun() explicitly signals that fun is defined externally, in another file. In practice, a bare int fun() at file scope already has external linkage by default, so the functional behavior is identical. The extern keyword is primarily a documentation signal about where the definition lives.

Patterns that speed up answering C aptitude questions

Four patterns recur across these ten questions. Recognising them reduces the chance of getting tripped by surface-level variation.

Array memory model: C provides no runtime bounds protection. Writing past the end of an array is undefined behavior, not a compile-time error. arr and &arr share the same numeric address but differ in type, which changes the step size of pointer arithmetic.

Pointer declaration reading: Apply the right-left rule. Start at the identifier, read right until you hit a ) or the end, then read left. For int (*ptr)[10]: start at ptr, read right to ), then left to * (pointer), then right to [10] (array of 10), then left to int. Result: pointer to an array of 10 integers.

Operator evaluation order: For pre/post increment questions, trace the state of every variable one statement at a time. Attempting to evaluate the whole expression at once is where candidates make errors.

Standard library precision: fmod() versus %, modf() versus fmod(). These questions test whether you know the exact contract of a library function, not just that it exists.

If aptitude-test logical and encoding patterns are also part of your preparation, the FACE Prep guide to coding and decoding aptitude question types covers the substitution cipher and number-series variants that appear alongside C questions in CoCubes and AMCAT tests.

The ten questions above reflect the C memory model that placement technical rounds at service companies test in their first screening stage. For product-company roles, practical AI fluency has become a second filter. TinkerLLM at ₹299 is where to start building with LLM APIs after the placement fundamentals are solid.

Primary sources

Frequently asked questions

What happens when you access an array element beyond its declared size in C?

The behavior is undefined. Modern compilers can detect this with address sanitizer flags at runtime, but the C standard provides no bounds protection. In practice the program overwrites adjacent memory and typically crashes.

What is the difference between arr and &arr for a C array?

Both expressions evaluate to the same numeric address, but their types differ. arr decays to int*, pointing at the first element. &arr has type int(*)[N], a pointer to the whole array. Pointer arithmetic on each moves by a different step size.

Why use fmod() instead of % for floating-point remainder in C?

The % operator in C works on integer operands only. For floating-point modulus, the standard library provides fmod(x, y), which returns the IEEE remainder of x divided by y. modf is a different function that splits a float into integer and fractional parts.

What are the three types of linkage in C?

External linkage covers global non-static variables and functions visible across translation units. Internal linkage covers static variables and functions with file scope. No linkage covers local variables inside a function block.

What special character is allowed in a C variable name?

Only the _ character. C identifiers may contain letters, digits, and the _ character. They cannot start with a digit, and no other special characters are valid.

What does int (*ptr)[10] declare in C?

It declares ptr as a pointer to an array of 10 integers. Compare this with int *ptr[10], which declares an array of 10 integer pointers. The parentheses change the binding order entirely.

What is the difference between extern int fun() and int fun() in C?

int fun() declares a function defined in the current file. extern int fun() signals that the function is defined externally, in another translation unit. Both have external linkage by default; the extern keyword is mainly a documentation signal about where the definition lives.

Build AI projects

A self-paced playground for building with LLMs.

TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.

Try TinkerLLM (₹299 launch)
Free AI Roadmap PDF