Fundamentals and Basic Concepts

Language Basics and History

  • What is C programming and why is it called a middle-level language?guvi+1
  • Who developed C language and when? What was its original purpose?data-flair+1
  • List and explain the features of C programming language.logicmojo+1
  • How does C differ from other programming languages like Java, Python, or C++?
  • What are the advantages and disadvantages of using C?
  • Why is C still relevant in modern computing despite being decades old?
  • What is the ANSI C standard and why is it important?
  • Explain the relationship between C and UNIX operating system.

Basic Data Types and Variables

  • What are the basic data types in C? Provide size and range for each.intellipaat+1
  • Explain signed and unsigned data types with examples.simplilearn
  • What are short, long, signed, and unsigned modifiers?simplilearn
  • How do you declare and initialize variables in C?
  • What is the difference between a variable and a constant?indeed
  • What are the rules for naming identifiers in C?
  • What happens when you don’t initialize a variable?guvi
  • Explain automatic type conversion and explicit type casting with examples.

Keywords, Tokens, and Identifiers

  • What are keywords in C? List some important keywords.interviewbit
  • What are the different types of tokens in C?interviewbit+1
  • Differentiate between keywords and identifiers.
  • What are reserved words in C programming?
  • Can you use keywords as variable names? What happens if you try?

Input/Output Functions

  • What is the purpose of printf() and scanf() functions?guvi+1
  • Explain different format specifiers with examples.interviewbit+1
  • What is the difference between printf() and puts()?
  • How do you handle input validation in C?
  • What are the return values of printf() and scanf()?
  • Explain buffer overflow vulnerabilities in input functions.

Operators and Expressions

Arithmetic And Assignment Operators

  • Explain all arithmetic operators in C with examples.
  • What is the difference between = and == operators?simplilearn
  • What are compound assignment operators?
  • How does integer division differ from float division in C?
  • What is operator precedence and associativity?

Increment And Decrement Operators

  • What is the difference between ++i and i++?prepinsta
  • What is the result of x = 5; y = x++ + ++x - --x + x--?data-flair
  • Explain undefined behavior in increment/decrement operations.guvi

Relational And Logical Operators

  • Explain all relational operators with examples.
  • What are logical operators and how do they work?
  • What is short-circuit evaluation in logical operators?
  • How does the conditional (ternary) operator work?simplilearn

Bitwise Operators

  • Explain all bitwise operators (&, |, ^, ~, <<, >>) with examples.geeksforgeeks+2
  • How do you set, clear, and toggle specific bits in a number?devinterview+2
  • Write a program to check if a number is a power of 2 using bit manipulation.interviewkickstart+1
  • How do you swap two numbers using XOR operation?geeksforgeeks
  • What is bit masking and when is it used?
  • How do you count the number of set bits in an integer?geeksforgeeks+1
  • How do you check if two integers have opposite signs using bitwise operations?aticleworld
  • Explain bit shifting operations and their applications.devinterview
  • How do you multiply or divide a number by powers of 2 efficiently?

Control Structures

Conditional Statements

  • Explain if, if-else, and nested if statements with examples.
  • How does the switch statement work? What are its limitations?
  • When should you use switch vs if-else statements?
  • What is the default case in switch statements?
  • Can you use floating-point numbers in switch statements?

Loops

  • Explain for, while, and do-while loops with examples.
  • What is the difference between entry-controlled and exit-controlled loops?simplilearn
  • How do break and continue statements work?
  • What are nested loops and when are they used?
  • How do you create an infinite loop and when might it be useful?

Jump Statements

  • Explain goto statement and why it should be avoided.
  • What are the uses of break, continue, and return statements?
  • Can you use goto to jump into a loop or out of a function?

Functions

Function Basics

  • What are functions in C? Why are they important?
  • How do you declare and define a function?
  • What is function prototyping and why is it necessary?simplilearn
  • What happens if you don’t declare a function prototype?
  • Can you call a function before its definition?

Function Parameters and Return Values

  • What is the difference between parameters and arguments?
  • Explain call by value vs call by reference.youtubesimplilearn
  • How do you return multiple values from a function?
  • What happens if you don’t specify a return type for a function?
  • Can a function return a pointer or an array?

Special Function Types

  • What are inline functions and how do they differ from macros?
  • What are function pointers and how do you use them?vervecopilot
  • Write a program demonstrating function pointers for a calculator.
  • What are callback functions?
  • How do you pass a function as an argument to another function?

Recursion

  • What is recursion? Provide examples.b2bcampus+1
  • What are the advantages and disadvantages of recursion?
  • How does recursion use the call stack?
  • What is tail recursion and how can it be optimized?
  • What causes stack overflow in recursive functions?

Variable Arguments

  • How do you create functions with variable number of arguments?
  • Explain stdarg.h library functions (va_start, va_arg, va_end).
  • Write a function that finds the sum of variable number of integers.

Arrays and Strings

Array Fundamentals

  • What is an array? How do you declare and initialize arrays?
  • What is the relationship between arrays and pointers?
  • How do you pass arrays to functions?
  • What are the limitations of arrays in C?
  • How do you find the size of an array using sizeof?

Multidimensional Arrays

  • How do you declare and use multidimensional arrays?simplilearn
  • How are 2D arrays stored in memory (row-major vs column-major)?
  • How do you pass 2D arrays to functions?

String Handling

  • How are strings represented in C?
  • What is the difference between char *str and char str[]?
  • Explain important string functions (strlen, strcpy, strcat, strcmp).
  • How do you copy a string safely to avoid buffer overflow?vervecopilot
  • What are the security implications of functions like gets() and strcpy()?

Pointers and Memory Management

Pointer Fundamentals

  • What is a pointer? How do you declare and initialize pointers?finalroundai+1
  • What is the difference between a pointer and a variable?finalroundai
  • How do you access the value at a pointer (dereferencing)?
  • What happens when you dereference a NULL pointer?guvi
  • What are the common uses of pointers?geeksforgeeks

Pointer Arithmetic

  • Explain pointer arithmetic with examples.aticleworld+1
  • How do you use pointer arithmetic to traverse arrays?finalroundai
  • What happens when you add or subtract integers from pointers?
  • Can you perform arithmetic operations between two pointers?

Advanced Pointer Concepts

  • What are void pointers and when are they used?intervue+1
  • What is a pointer to a pointer? Provide examples.finalroundai
  • What are function pointers and how do you use them?
  • How do you create and use arrays of pointers?
  • What are pointers to arrays vs arrays of pointers?

Pointer Problems and Pitfalls

  • What are dangling pointers and how do they occur?toptal+2
  • What are memory leaks and how do you prevent them?intervue+1youtube
  • What is a wild pointer?
  • What are the common mistakes when using pointers?finalroundai
  • How do you debug pointer-related issues?

Dynamic Memory Allocation

  • Explain malloc(), calloc(), realloc(), and free() functions.interviewkickstart+1
  • What is the difference between malloc() and calloc()?aticleworld+1
  • When should you use malloc() vs calloc()?aticleworld
  • How do you handle memory allocation failures?
  • What happens if you forget to call free()?interviewkickstart
  • How do you resize dynamically allocated memory?interviewkickstart
  • What are memory leaks and how do you detect them?interviewkickstart
  • Write a program to create a dynamic array and perform operations on it.finalroundai
  • How do you implement a dynamic string?

Memory Management Best Practices

  • What are the best practices for memory management in C?aticleworld
  • How do you avoid double free errors?
  • What tools can help detect memory leaks?
  • How do you implement custom memory allocators?

Structures, Unions, and Enumerations

Structures

  • What is a structure? How do you define and use structures?
  • How do you access structure members?
  • What is the difference between . and -> operators?
  • How do you pass structures to functions?
  • Can you return a structure from a function?
  • What is a nested structure?
  • How do you create an array of structures?

Structure Memory Layout

  • What is structure padding and alignment?guvi
  • How does the compiler decide on padding in structures?
  • How can you minimize structure padding?
  • What is #pragma pack and when is it used?
  • How do you calculate the size of a structure?

Unions

  • What is a union and how does it differ from a structure?
  • When should you use unions instead of structures?
  • How do you safely access union members?
  • What is an anonymous union?
  • Can you have structures within unions and vice versa?

Enumerations

  • What are enumerated types (enums) and why are they useful?
  • How do you define and use enums?
  • What are the underlying values of enum constants?
  • Can you assign custom values to enum constants?

Advanced Structure Concepts

  • How do you create self-referential structures?
  • What are bit fields in structures and when are they used?vervecopilot
  • How do you implement linked lists using structures?
  • What are flexible array members in structures?

File Handling

File Operations Basics

File Input/Output Functions

  • Explain fprintf(), fscanf(), fgets(), and fputs() functions.geeksforgeeks
  • What is the difference between fgetc() and getc()?
  • How do you read and write binary data to files?geeksforgeeks

File Positioning Functions

  • Explain fseek(), ftell(), and rewind() functions.cppbuzz+1
  • How do you move the file pointer to a specific position?
  • What is the difference between fseek() and rewind()?letsfindcourse
  • How do you get the current position of the file pointer?

File Handling Problems

  • How do you read a file line by line?w3resource
  • How do you handle errors in file operations?

Advanced File Concepts

  • What is the difference between buffered and unbuffered I/O?
  • How do you flush file buffers?
  • What are standard input, output, and error streams?letsfindcourse
  • How do you redirect input and output in C programs?

Preprocessor Directives

Basic Preprocessor Directives

  • What is the preprocessor and when does it run?
  • Explain #include, #define, and #undef directives.
  • What is the difference between #include <file> and #include "file"?vervecopilot
  • How do you create and use header files?

Macros

  • What are macros and how do they differ from functions?vervecopilot
  • What are the advantages and disadvantages of macros?
  • How do you create function-like macros?
  • What are the potential pitfalls of using macros?
  • Write a macro to find the maximum of two numbers.

Conditional Compilation

  • Explain #ifdef, #ifndef, #if, #else, and #endif directives.data-flair
  • How do you use conditional compilation for debugging?data-flair
  • What are header guards and why are they important?
  • How do you create platform-specific code using preprocessor directives?

Advanced Preprocessor Features

  • What are #pragma directives and when are they used?
  • Explain #error and #warning directives.
  • What are predefined macros like __FILE__, __LINE__, __DATE__?
  • How do you create variadic macros?

Advanced C Programming Concepts

Storage Classes

  • Explain different storage classes: auto, register, static, extern.vervecopilot+1
  • What is the difference between local and global variables?
  • How does the static keyword affect variables and functions?vervecopilot
  • When should you use the register storage class?
  • What is the scope and lifetime of different storage classes?

Type Qualifiers

  • What is the const qualifier and how do you use it?vervecopilot
  • What is the volatile keyword and when is it necessary?simplilearn+1
  • Can you modify a const variable indirectly through pointers?
  • What are restrict and _Atomic qualifiers?

Advanced Data Types

  • What is typedef and why is it useful?vervecopilot
  • How do you create complex data types using typedef?
  • What are incomplete types in C?
  • How do you work with void pointers safely?
  • What are variadic functions and how do you implement them? Variable Arguments
  • How do you implement function overloading in C?
  • What are nested functions and do they exist in C?
  • How do you implement closures in C?

System Programming and Low-Level Concepts

Memory Layout and Management

  • Explain the memory layout of a C program (code, data, heap, stack).geeksforgeeks+1
  • What is the difference between stack and heap memory?guvi+1
  • How does the call stack work?
  • What causes stack overflow and heap overflow?
  • How do you detect and prevent buffer overflows?vervecopilot

Endianness And Data Representation

  • What is endianness (big-endian vs little-endian)?
  • How do you check the endianness of a system?
  • How are negative numbers represented in C (two’s complement)?
  • What is the IEEE 754 standard for floating-point representation?

System Calls and Library Functions

  • What is the difference between system calls and library functions?
  • How do you make system calls from C programs?
  • What are some common POSIX functions?
  • How do you handle signals in C programs?

Performance Optimization

  • What are the common optimization techniques in C?
  • How do you profile C programs to find performance bottlenecks?
  • What is the role of compiler optimizations?
  • How do you write cache-friendly code?
  • What are the trade-offs between speed and memory usage?

Error Handling and Debugging

Common Errors and Debugging

  • What are syntax errors, runtime errors, and logical errors?indeed+1
  • What is a segmentation fault and how do you debug it?usebraintrust+1
  • How do you debug a C program effectively?getsdeready+2
  • What tools can you use for debugging C programs (GDB, Valgrind)?b2bcampus
  • How do you use assert() macro for debugging?data-flair
  • What are buffer overflows and how do you prevent them?
  • How do you detect memory leaks using tools?getsdeready
  • What are use-after-free errors and how do you avoid them?
  • How do you debug double-free errors?

Best Practices for Error Prevention

  • How do you write defensive code in C?
  • What are coding standards and why are they important?
  • How do you handle error conditions gracefully?
  • What is the importance of code reviews in preventing errors?

Embedded and System-Level Programming

Embedded C Concepts

  • What is Embedded C and how does it differ from standard C?finalroundai
  • How do you program microcontrollers using C?finalroundai
  • What are registers and how do you access them in C?finalroundai
  • How do you implement interrupt service routines (ISRs)?finalroundai
  • What is memory mapping in embedded systems?finalroundai

Real-Time Programming

  • What are the challenges of real-time programming in C?
  • How do you ensure deterministic behavior in C programs?
  • What are watchdog timers and how do you implement them?

Hardware Interface Programming

  • How do you interface with hardware devices using C?
  • What are device drivers and how are they written in C?
  • How do you implement communication protocols (UART, SPI, I2C)?finalroundai

Advanced Topics and Tricky Questions

Undefined Behavior and Implementation-Defined Behavior

  • What is undefined behavior in C and why is it dangerous?guvi
  • Provide examples of undefined behavior.guvi
  • What is implementation-defined behavior?
  • How do you write portable C code?

Tricky C Questions

  • What is the value of the expression 5["abcdef"]?interviewbit
  • Explain the behavior of printf("%d");intervue
  • What happens when you call main() recursively?
  • How do you print the symbol % using printf()?intervue
  • What is the output of printf("GeeksQuiz"); without #include <stdio.h>?

Advanced Pointer Manipulations

  • What are the different levels of pointer indirection?
  • How do you create and use arrays of function pointers?
  • What are const pointers vs pointers to const?
  • How do you implement generic programming using void pointers?

Compiler And Linking Concepts

  • What happens during the compilation process (preprocessing, compilation, assembly, linking)?
  • What is the difference between compilation errors and linking errors?
  • How do you create and use static and dynamic libraries?geeksforgeeks
  • What are symbol tables and how do they work?

Interview Scenario and Coding Problems

Classic Programming Problems

  • Write a program to check if a number is prime.geeksforgeeks+1
  • Implement the Fibonacci sequence using different approaches.data-flair
  • Write a program to find all prime numbers up to n (Sieve of Eratosthenes).
  • Implement string manipulation functions (reverse, palindrome check, anagram detection).
  • Write a program to convert decimal to binary and vice versa.finalroundai

Mathematical Problems

  • Write a program to find GCD and LCM of two numbers.
  • Implement integer square root without using library functions.
  • Write a program to generate Pascal’s triangle.
  • Implement matrix operations (addition, multiplication, transpose).

Pattern And Series Problems

  • Write programs to print various number and star patterns.
  • Generate arithmetic and geometric progressions.
  • Print Pascal’s triangle, Floyd’s triangle.

Problem-Solving Scenarios

  • How would you implement a memory pool allocator?
  • Design a simple garbage collector for C.
  • How would you implement a basic operating system scheduler?
  • Design a simple interpreter for a mathematical expression evaluator.

Advanced System and Performance Questions

Concurrency And Multi-threading

  • How do you handle multi-threading in C programs?
  • What are race conditions and how do you prevent them?
  • What are mutexes, semaphores, and condition variables?
  • How do you implement producer-consumer problems?

Network Programming

  • How do you create client-server applications using sockets?
  • What are the differences between TCP and UDP programming?
  • How do you handle network byte order conversion?

Performance Analysis

  • How do you measure the performance of C programs?
  • What are cache misses and how do they affect performance?
  • How do you optimize code for specific architectures?
  • What is branch prediction and how does it affect performance?

Modern C Standards and Features

C99, C11, C18 Features

  • What are the key features introduced in C99?
  • What new features were added in C11?
  • How do you use variable-length arrays (VLAs)?
  • What are compound literals and designated initializers?
  • How do you use the _Generic keyword for type-generic programming?

Security Considerations

  • What are buffer overflow attacks and how do you prevent them?
  • How do you write secure C code?
  • What are format string vulnerabilities?
  • How do you validate input to prevent security issues?

Miscellaneous Questions

  1. right rotate array
  2. stack using queue - costly push operation