Lesson 15 — Advanced

Top 50 C Programming Interview Questions

Ye hai wo 50 sawal jo C interviews mein sabse zyada aate hain — entry-level se lekar experienced tak. Har answer ek line mein. Inhe padh lo, apne hisaab se code likh ke dekho, aur interview mein confident bolo.

⏱ 20 min• Advanced• All lessons

Basics, types & operators (Q1-12)

WHAT

Ye 50 questions C interviews aur exams mein sabse zyada poochhe jaate hain — concepts, output aur traps. Har sawal ka ek line answer diya hai, saath mein wo keyword jo interviewer sunna chahta hai.

WHEN

Interview se 1 din pehle revise karo, test se raat ko, ya course ke baad ek baar revise — har stage pe ye list kaam aati hai. Roz 10 questions ki aadat daalo.

WHERE

TCS/Infosys/Wipro ke technical rounds, college viva, GATE prelims aur placement coding tests — C ke sawal yahin sab jagah ghoomte hain.

Shuruaat sabse fundamental se — ye 12 har entry-level interview mein ghoom ke aate hain:

Q1.  C kisne banayi?        → Dennis Ritchie, 1972, Bell Labs
Q2.  C kis se bani?         → B language (B ← BCPL) — mid-level
Q3.  Entry point?           → int main()
Q4.  #include ka kaam?      → preprocessor header paste karta hai
Q5.  Compilation stages?    → preprocessor, compiler, assembler, linker
Q6.  int / char ki size?    → 4 bytes / 1 byte (typical)
Q7.  7/2 ka output?          → 3 (integer division — trap!)
Q8.  = vs ==?                → assignment vs comparison
Q9.  ++i vs i++?             → pehle increment vs baad mein increment
Q10. True/false C mein?      → true = 1, false = 0 (non-zero bhi true)
Q11. & aur * operator?       → address lena / value nikalna (dereference)
Q12. % operator?             → modulus (remainder) — even/odd check
Tip: Ye 12 interview ka foundation hain. Har ek ka answer bolne ke saath ek line example do — "7/2 = 3 kyunki dono int, float chahiye toh cast" — impress ho jaayenge.

Control flow, arrays & strings (Q13-24)

Q13. for vs while?         → fixed count vs condition based
Q14. do-while ka fark?      → kam se kam ek baar chalta hai
Q15. break vs continue?     → poora loop band vs iteration chhod
Q16. Infinite loop kaise?    → while(1), for(;;)
Q17. switch mein break?      → fall-through se bachne ke liye
Q18. Array index kahan se?   → 0 se, last = size - 1
Q19. Bounds check hota hai?  → NAHI — C mein (undefined behaviour)
Q20. a[5] of int[5] size?    → 5 * 4 = 20 bytes
Q21. String kya hai?         → char array jo '\0' par rukta hai
Q22. strlen vs sizeof?       → characters vs poora array bytes
Q23. gets() kyun nahi?       → buffer overflow — fgets use karo
Q24. strcmp return?          → 0 equal, <0 / >0 order (lexicographic)

Strings wale 4 questions (Q21-24) har junior interview mein aate hain — \0 ka concept aur strcmp ka 0 ye do lafz zaroor bolna.

Functions & pointers (Q25-37)

Q25. Prototype kyun?       → compiler ko signature pehle chahiye
Q26. Pass by value?         → copy jaati hai, original change nahi
Q27. Call by reference kaise? → pointer (&) bhej kar
Q28. fact(5)?                → 120 (recursion ka output)
Q29. Recursion base case?    → zaroori — warna stack overflow
Q30. static variable?        → calls ke beech value yaad rakhta hai
Q31. Global vs local?        → poori file vs function ke andar
Q32. Pointer kya hai?        → kisi variable ka ADDRESS store karta hai
Q33. NULL pointer?           → kisi valid object ka address nahi
Q34. Dangling pointer?       → freed/destroyed memory ka address
Q35. Array function mein?    → pointer decay — size alag se do
Q36. int *p++ ka matlab?     → 4 bytes (int) aage — element size se
Q37. Swap kaise?             → & se address bhejo, * se value badlo
Power section: Pointers (Q32-37) sabse zyada poochhte hain. Inme se swap wala (Q37) toh live-coding mein likhwane ko bhi milta hai — practice kar ke jaana.

Struct, file, memory & preprocessor (Q38-50)

Q38. Struct vs union?      → alag memory vs ek shared memory
Q39. . vs -> ?               → value ke liye vs pointer ke liye
Q40. typedef?                → type ko alias/naam deta hai
Q41. enum default?           → pehla = 0, agle +1
Q42. FILE* kya hai?          → file handle (stdio.h) — fopen return
Q43. "w" vs "a" mode?        → pura wipe vs end mein append
Q44. fopen fail?             → NULL — check karo warna crash
Q45. fclose kyun?            → buffer flush + resource free
Q46. malloc vs calloc?       → garbage vs ZERO (+ 2 arguments)
Q47. realloc?                → block ka size badalna (grow/shrink)
Q48. Memory leak?            → free kiya bina heap block kho jaana
Q49. Preprocessor vs compiler? → text replace vs code→assembly
Q50. Macro ka danger?        → no type check + precedence bug

Ye 13 advanced hain — yahan interviewer yeh dekhta hai ki tumne sirf syntax nahi, memory samjhi hai ya nahi. Q46-Q48 ka "leak/NULL/free" wala triangle har C interview mein ghoomta hai.

Final tip: In 50 mein se 30+ har CS interview mein aate hain. Roz 10 revise karo — 5 din mein sab yaad. Aur haan: padhne ke baad 5-6 programs compiler pe likh bhi lo, warna bolne mein hichkichahat aayegi.

Exercise

Question: C banane wale vyakti ka poora naam? (space se likho)

Question: fact(6) kitna hota hai? Sirf number daalo.

Question: malloc aur calloc mein se kaunsa zero-filled memory deta hai?

Question: Swap ke liye function ko value bhejne ki jagah kya bhejna chahiye? (address / pointer)

Common mistakes

Desi example: Interview se pehle ki 5-minute checklist

Interview hall mein baithe ye 5 revise kar lo — inhi se 80% coverage: Ye 5 hi aksar ghoom ke aate hain:

text
1. Compilation 4 stages + entry point main()
2. 7/2 = 3 + i++ vs ++i (operators ke traps)
3. \0 + strcmp return 0 (strings)
4. & + * + swap by pointer (pointers = king)
5. malloc/free + "w" vs "a" (memory + files)
Ye 5 = 80% C interview coverage
Exam mapping (TCS / Infosys / Wipro)
  • TCS NQT: C se 8-10Q — output + basics (7/2, ++i, \0, modes).
  • Infosys: conceptual explain karna padta hai — pointer/union wale.
  • Wipro/other: speed + accuracy — ye 50 questions cover kar lete hain.
  • College exam: top 15 questions mein se program likhwane wale bhi hain (swap, palindrome, factorial).
Lesson complete?

Course complete! 🎉 tumne C programming ka poora path cover kar liya. Ab DSA ya Python path pe jao — C ka foundation tumhe aage sabse aage rakhega.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course