issue 117apr 27mmxxvi
est. 2017
Sun, 27 Apr 2026
vol. IX · no. 117
PapersAdda
placement intelligence, since 2017
640+ briefs · 24 campuses · by reservation
verified offers · sourced from r/developersIndia
razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1

C Output Prediction Questions 2026: 30 Tricky Snippets

8 min read
Interview Questions
Updated: 8 Jun 2026
Aditya Sharma
Aditya's Edit

PapersAdda 2026 Placement Cycle

By Aditya Sharma·Founder & Editor, PapersAdda

What changed in 2026 drives

Mass-recruiter offer letters are flatter for 2026 batch - the 4-5 LPA ASE band has barely budged in three years while inflation eats real wages. Premium tracks (Digital, Pro, Elite, Specialist) are still where the differential lives, and they are entirely test-driven. If you are aiming higher than the default offer, the coding round is not optional pageantry - it is the entire interview.

What I'd actually study for this

  • 01Two solid coding-round answers (1 medium-hard DSA each, with edge-case discussion) > five half-baked ones
  • 02One real project you can defend end-to-end - file paths, design decisions, and what you would change
  • 03One DBMS schema you actually built (not a textbook ER diagram), with at least 3 join-heavy queries written from memory
  • 04Three behavioural STAR stories: failure recovered, conflict handled, ownership taken

Where most candidates trip up

The single biggest mistake is treating company-specific guides as primary prep and DSA as secondary. It is the opposite. Mass recruiters use the test as a filter, but premium tracks at every IT services company use coding to allocate offer band. Spend 70% of prep time on DSA + system fundamentals, 20% on company-specific patterns, 10% on HR rehearsal. Reverse that ratio and you collect the default offer.

Editorial commentary by Aditya Sharma · written for PapersAdda · not generated, not aggregated.

Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~16 min

C output questions test whether you understand the language at the level of bytes, sequence points, and promotion rules. Candidates report these dominate core-CS MCQ screens and aptitude rounds. This guide gives 30 snippets with the exact output and a precise explanation, and it honestly flags the cases that are undefined behaviour rather than pretending they have one answer. Behaviour reflects the official C language references; confirm any edge case on the standard.

Pair this with C Programming Placement Questions and C Pointers Interview Questions 2026.


Table of Contents

  1. Operators and Promotion (Q1 to Q9)
  2. Pointers and Arrays (Q10 to Q18)
  3. Format Specifiers and Chars (Q19 to Q24)
  4. Undefined Behaviour and Tricky (Q25 to Q30)
  5. Quick Trap Table
  6. Frequently Asked Questions

Operators and Promotion

Q1.

int x = 5;
printf("%d", x++ + ++x);

Output: 12 Why: x++ yields 5 (x becomes 6), ++x makes x 7 and yields 7. 5 + 7 = 12. Note: some compilers treat this as relying on evaluation order, so check the exact form your interviewer uses.


Q2.

printf("%d", 5 / 2);
printf(" %d", 5 % 2);
printf(" %.1f", 5.0 / 2);

Output: 2 1 2.5 Why: Integer division truncates, modulus gives remainder, and float division keeps the fraction.


Q3.

int a = 10, b = 3;
printf("%d", a > b ? a : b);

Output: 10 Why: The ternary returns a since a > b is true.


Q4.

printf("%d", 1 << 3);
printf(" %d", 8 >> 2);

Output: 8 2 Why: Left shift multiplies by powers of two, right shift divides.


Q5.

int x = 10;
printf("%d", x > 5 && x < 20);
printf(" %d", !0);

Output: 1 1 Why: True logical expressions evaluate to 1 in C; !0 is 1.


Q6.

char c = 'A';
printf("%d", c);
printf(" %c", c + 1);

Output: 65 B Why: A char promotes to its ASCII int 65; adding 1 and printing as char gives 'B'.


Q7.

int x = -5;
printf("%u", x);

Output: (a large number like 4294967291) Why: Printing a negative int with %u reinterprets its two's-complement bits as unsigned, giving a large value.


Q8.

printf("%d", sizeof(int));
printf(" %d", sizeof('A'));

Output: 4 4 Why: sizeof(int) is typically 4. In C, a character constant has type int, so sizeof('A') is also 4 (unlike C++ where it is 1).


Q9.

int i = 5;
printf("%d", i = 10);

Output: 10 Why: An assignment expression evaluates to the assigned value, 10.


Pointers and Arrays

Q10.

int a[] = {1, 2, 3, 4};
printf("%d", *(a + 2));

Output: 3 Why: *(a+2) is a[2], the third element.


Q11.

int a[] = {1, 2, 3};
printf("%ld", sizeof(a) / sizeof(a[0]));

Output: 3 Why: Total array bytes divided by one element's bytes gives the element count, the standard length idiom.


Q12.

char *s = "hello";
printf("%c", s[1]);
printf(" %c", *(s + 4));

Output: e o Why: Index and pointer arithmetic are equivalent; s[1] is 'e', *(s+4) is 'o'.


Q13.

int a[] = {10, 20, 30};
int *p = a;
p++;
printf("%d", *p);

Output: 20 Why: Incrementing the pointer moves it to the next int.


Q14.

int x = 5, *p = &x;
*p = *p + 10;
printf("%d", x);

Output: 15 Why: Writing through the pointer updates x to 15.


Q15.

char str[] = "abc";
printf("%lu", sizeof(str));
printf(" %lu", strlen(str));

Output: 4 3 Why: sizeof counts the null terminator (4 bytes); strlen counts only visible characters (3).


Q16.

int a[3] = {1, 2, 3};
printf("%d", a[3]);

Output: (undefined behaviour) Why: Index 3 is out of bounds for a size-3 array; reading it is undefined, often garbage. The correct interview answer names it as undefined.


Q17.

int *p = NULL;
printf("%d", p == NULL);

Output: 1 Why: The comparison is true (1) because p is null. Note we compare, not dereference.


Q18.

int a[] = {1, 2, 3};
printf("%d", 2[a]);

Output: 3 Why: a[i] is *(a + i) which is commutative, so 2[a] equals a[2], the value 3. A favourite trick.


Format Specifiers and Chars

Q19.

float f = 3.14;
printf("%d", f);

Output: (undefined / garbage) Why: Printing a float with %d is a format mismatch and undefined behaviour. The correct answer flags the mismatch.


Q20.

printf("%d", printf("hi"));

Output: hi2 Why: Inner printf prints "hi" and returns the count 2, which the outer prints.


Q21.

int x = 65;
printf("%c", x);

Output: A Why: %c interprets the int 65 as the ASCII character 'A'.


Q22.

printf("%d %d", 1);

Output: 1 (garbage) Why: Fewer arguments than specifiers reads an indeterminate value for the second, undefined behaviour. Flag it.


Q23.

char c = 130;
printf("%d", c);

Output: (implementation-defined, often -126) Why: A signed char overflows past 127; the result wraps, which is implementation-defined. Many systems print -126.


Q24.

printf("%3d", 5);
printf("|%-3d|", 5);

Output: 5|5 | Why: %3d right-justifies in width 3; %-3d left-justifies.


Undefined Behaviour and Tricky

Q25.

int i = 5;
i = i++;
printf("%d", i);

Output: (undefined behaviour) Why: Modifying i twice without a sequence point is undefined in C. Do not assume a fixed result; the standard does not define one.


Q26.

int i = 0;
int a[] = {10, 20, 30};
a[i] = i++;
printf("%d %d", a[0], a[1]);

Output: (undefined behaviour) Why: The index and the side effect on i are unsequenced, so the result is undefined. Recognising this is the answer.


Q27.

#define SQ(x) x * x
printf("%d", SQ(2 + 3));

Output: 11 Why: Text substitution gives 2 + 3 * 2 + 3 = 11, not 25. Always parenthesise macro arguments: ((x)*(x)).


Q28.

int x = 10;
{
  int x = 20;
  printf("%d", x);
}
printf(" %d", x);

Output: 20 10 Why: The inner block's x shadows the outer one inside the block; outside, the outer 10 is visible.


Q29.

int a = 1, b = 2;
a ^= b ^= a ^= b;
printf("%d %d", a, b);

Output: (undefined behaviour) Why: This XOR-swap idiom modifies a multiple times without a sequence point, which is undefined in C. Use a temp variable.


Q30.

printf("%d", 10 + 20 == 30);

Output: 1 Why: Addition binds tighter than ==, so 30 == 30 is true (1).


Quick Trap Table

TrapRule to remember
i = i++undefined, no sequence point
char constant sizeint (4) in C
%d with floatundefined format mismatch
out-of-bounds indexundefined behaviour
2[a]same as a[2]
macro without parenstext substitution surprises
%u with negativereinterprets bits
sizeof vs strlenincludes null vs excludes

Frequently Asked Questions

Are output prediction questions common in C interviews in 2026?

Yes. Candidates report that C MCQ screens and aptitude rounds lean heavily on output prediction for pointer arithmetic, operator precedence, integer promotion, and the classic undefined-behaviour traps.

What is the most common C output trap?

Sequence-point and undefined-behaviour expressions like i = i++ or a[i] = i++, where the standard does not define a single result. Recognising that they are undefined is the correct answer.

How do I get fast at C output prediction?

Master operator precedence, pointer arithmetic scaling by type size, integer and char promotion, format-specifier mismatches, and the sequence-point rules. Trace each expression carefully and flag undefined behaviour.

Why is i = i++ undefined rather than just returning a value?

Because the C standard requires a sequence point between modifications of the same object in one expression, and i = i++ modifies i twice without one. The compiler is free to produce any result, so the honest answer is undefined.

Why does SQ(2 + 3) give 11 instead of 25?

Because the macro is plain text substitution, expanding to 2 + 3 * 2 + 3, where multiplication binds first. Parenthesising the macro and its arguments as ((x)*(x)) fixes it.



Where an output is undefined, this guide says so honestly rather than asserting a fixed value. Confirm any edge case on the official C language references. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.

Methodology applied to this articlelast verified 8 Jun 2026
Sources used
Public exam-pattern documents, official recruiter pages, and verified candidate reports on r/developersIndia and LinkedIn.
Verification window
Page last edited 8 Jun 2026 by Aditya Sharma. Numbers and patterns sanity-checked against the most recent 2026 cycle drives we tracked.
What we did NOT do
  • No fabricated salary numbers or success rates. If we quote a range, it's sourced.
  • No noun-substituted templates. This article was not generated by swapping company names in a stock prompt.
  • No paid placements, sponsored coaching links, or affiliate-shilled course pushes.
Verification policy: /editorial-standards/. Found something incorrect? Submit a correction - we respond within 48 hours.

Explore this topic cluster

More resources in Interview Questions

Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.

Paid contributor programme

Sat this this year? Share your story, earn ₹500.

First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story - with byline.

Submit your story →

Ready to practice?

Take a free timed mock test

Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.

Start Free Mock Test →

Related Articles

More from PapersAdda

Share this guide: