248 Exam and interview questions on C language for developers/learners. Click on the link to get the detailed explanations. One you visit any answer you can navigate through next and previous link to jump from one answer to another. You can also select index to come back to this index page. Please provide us the rating and feedbacks of our questions and answers.
History and background
- History of programming languages?
- History of C programming language.
- Do I need to learn flow chart and pseudo codes before implementing a C program?
- Importance of C, Practical applicability, programming language should we learn after C, type of job openings.
- What are the common C compilers and editors available?
- Describe details of Turbo/Borland C, GCC, VC++, Watcom C, DJGPP, Xcode.
Program and programming elements
- How to write my first C program? Explain the structure of a simple C program?
- Explain include header files, linking library, compilation/building and running?
- Explain briefly about pre-processing, compilation, optimization and linking format.
- How to debug a program using GDB and Explain briefly about various options of GDB.
- Why is C called a structured programming language?
Datatypes and storage
- What are the basic data types supported? [char, short, int, long, float, double, long double]
- what are the storage classes in C? [auto, register, global, static, volatile]
- What is a volatile variable in C?
- Differentiate between external and static variable?
- Differentiate between global and static variable?
- Differentiate between register and auto variable?
- What is a constant variable and constant string?
- What is the value of sizeof(void)?
Statements and Decision making
- How to write a decision making statements with if, if else, if else if?
- How to jump to a particular program section with goto and label? [explain with example]
- How to use switch case statement? Explain with source code example
- What will be the output? int i=-10; if(i=-10) printf('i is -10') else printf('i is not -10'); int i=0; if(i=0) printf('i is 0') else printf('i is not 0');
- What will be the output? [topic: expression execution sequence]
- How to write repetitive statements in C? [for, while, do while example, flowchart]
- Write syntax for for-loop, while-loop and do while loop?
- Convert for loop statement to while loop and vice versa?
- When is do-while loop preferred over while loop, Give example?
- Write infinite loop statements for 'while', 'do-while' and 'for'?
- How to break a loop? How to skip loop iterations with continue? [example and flowchart]
- Write a switch statement that prints statement1 for 1-10 and 15-20 else print statement2?
- Can you place a continue statement in switch-case block?
Logical and bitwise Operators
- What are the basic operators available in C ? Write some expressions with these operators.
- What are the logical operators available in C ? Give examples.
- What are the bitwise operators available in C ? How these are different than logical operators? Give examples.
- What will be the value? [topic: logical and bitwise or operator]
- What are bit shifting operators available in C ? Give examples.
- How to obtain bit mask between two bit positions?
- How to reverse bits of a 32bit unsigned integer? explain with example
- How to swap between two neighbor bits?
- How to set a bit, clear a bit and toggle a bit in a perticuler position in a bit pattern?.
- What is the value of c after execution of this statement c = c ^ c;?
- What is the value of c if unsigned char c = 10; c >>= 8 or c <<= 8?
- What are the precedence in Operators ? Give examples.
- If i = 10 and j = 20; then the value of k,i,j? after execution of statement k= i+++j;
- How can I reduce the statements in one line? [topic: ternary operator]
Console Input output
- How printf and scanf function works in c internally? (implementation of printf and scanf)
- How can a pointer to int and pointer to void be printed using prinf?
- In the statement scanf('%s',str); where str is a char buffer, user gives 'How are you', then what str will contain after execution of scanf?
- How can a string with blanks be scanned using scanf?
- How can I scan a string until user presses enter?
- What does scanf return?
- What does printf return?
- What will be the output printf('%d',scanf('%c',str)); if user enters anything?
- Can I print string into console using fprintf?
- Can I get user input using fscanf?
- What is the default print format for floating point in printf? How can I print a floating point up to two decimal places?
- What is a pointer type in C? What are the common issues happened when mishandled?
- Why does the statement char *str = 'Hello'; work, but not int *i = 10;?
- What will be the output?[topic: long pointer increment]
- What will be output? [topic: short pointer increment]
- What will be output? [topic: short pointer increment]
- What is Memory Model in DOS compiler and what are near, far and huge pointer?
- Why typed pointers like int*,char* are there when a void pointer is sufficient to store address of any variable or any memory location ?
- What will happen if I compile the code void *v = malloc(sizeof(void)); v++;?
- Will the following operations +,-, ++,-- work with void pointer?
Dynamic memory handing
- Where do the addresses of local and dynamic located? Here i and j are inside a function, statements are int i = 10; int *j = (int*)malloc(sizeof int);
- Differentiate between malloc and calloc?
- What is NULL pointer? Is NULL is 0?
Emum and macros
- What is an enums or enumerator type? [Describe with example]
- What is macro and how to use it? [Describe with source code]
- Differentiate between #define PI 3.1429 and const float PI 3.1429?
- What is the difference between enumeration and macro?
- Differentiate between macro and typedef?
- How can I write a code for both debug and release version but my debug version will only contain debug tracing and assertion checking.
- How can I stop compilation of my code if the compiler is not a c++ compiler?
- How can I print current source file path, current line number, date and time in a program?
- What is token pasting?
- What is Characterizing?
Array and Multidimentional Array
- What is array in C? Explain array initialization, allocation, calculate size and element count
- How to define multidimensional arrays (like 2D and 3D)? What are their utilities?
- How to allocate 2D and 3D dynamic array? Explaind with source code
- Write a program to add two Matrix?
- Write a program to multiply two Matrix?
- Write a program to print adjacency matrix.
Strings and string checking
- What is the difference between char str = 'Hello World';and char *str='Hello World';?
- Differentiate between const char *,char * const, const char * const?
- How to check if a character is alpha numeric?
- What is a palindrome string?
- How to convert upper case to lower vice versa?
- How to convert string to integer?
- How to convert integer to string?
Experiments with Integers
- How to reverse the digits of a decimal number?
- What will be the output? [topic: signed and unsigned variable assignment compare]
- How to check if digits of a number are Palindrome?
- Suggest three operation to get the value of lower 16 bit and upper 16 bit short/word of a 32 bit int variable.
- How to Exchange two variables without any third variable?
Prime numbers and number factors
- How to write a logic for detecting a prime number?
- What is Highest Common Factor(HCF) of two numbers? How to calculate it using C?
- What is Lowest Common Multiple(LCM) of two numbers? How to calculate it using C?
Printing star triangles
User defined data types
- What are user defined data types supported in C?
- What is typedef in C? How to define new types ?
- What is structure data type?
- What is an union data type?
- Differentiate between structure and union?
- What is packing in structure and how compiler adds padding between member elements?
- What is the size of a structure?
- What is bit fields? How to define and use bit fields?
- What is l-value? Is both structure and array are l-value?
Functions and functions calls
- What is function prototype declaration, and definition?
- What is calling convention in C and C++?
- How does calling convention in C/C++ differ with PASCAL?
- While linking source code, we get linking error for the functions those do not have any body or definition but it properly links library functions even if function bodies never included in source, why?
- What is call by value vs call by reference with example code and diagram?
- How parameters are passed using call by value?
- How parameters are passed using call by reference?
- How to pass a structure to a function argument?
- How to pass an array to a function argument?
- What is inline function? What is its utility?
- Differentiate between macro and inline function?
- What is function pointer? How does it work, give example?
- What will be the output? [topic: default C++ function argument value]
Recursion and number series
- What is Recursion? How is this helpful and where it is used?
- How to calculate Factorial using recursion and non-recursion?
- How to calculate Fibonaci Number using recursion and non recursion?
- How to generate Armstrong number?
Variadic Function and macros
- What is variadic function and how arguments are processed?
- What is variadic macro?
- How can printf() and scanf() take multiple arguments?
Memory and string functions
- Construct your own strcpy and strcat/implementation of strcpy, strcat function in C
- memmove vs memcpy how different? implement your own code?
- How strrev() works? Explain working principle with source code.
- How to duplicate a string? (String duplication with strdup)
- How to split/tokenize a string? (strtok() string tokenizer)
- What will be the value of x?[topic: proper macro definition]
- How exceptions are handled in C? (return check, exit to OS in fatal error, NULL check, setjmp-longjmp)
- What is setjmp and longjmp in C? How to handle C++ like try-catch exceptions in C?
Memory handling issues
- What is memory leak? How to check memory leak in c program?
- What is memory corruption and how to detect memory corruption?
- What is Big Endian and Little Endian? How to detect it in C?
- How to know stack grows in which direction -upper or lower?
Data structure and array
Linked list Queue, Stack
- What is a Linked List? How to implement it? What are the types of lists used in C?
- What is Single Linked list? Implement Single Linked list with example.
- What is Doubly Linked list? Implement Doubly Linked list with example.
- What is Circular Linked list? Implement Circular Linked list with example.
- What is Doubly Circular Linked list? Implement Doubly Circular Linked list with example.
- What is Queue? How to implement queue in C? Explain with an example.
- How to reverse single linked list?
- How to delete a node at a given position of a single linked list?
- What is Stack? How to implement stack in C? Explain with an example.
Tree Data structure and algorithms
- What is tree data structure? What is binary tree and the utility? Explain with an example.
- What is a Binary tree? How to implement binary tree in C?
- How to traverse a Binary tree?
- What is a Binary search tree? How to implement it?
- How to double a binary tree?
- How to mirror a binary tree?
- How to find out the max height of a binary tree?
- What is Heap data structure? Explain with an example.
- What is Complexity? Explain Complexity with C examples.
- What is Linear Search? Explain Linear Search with C source code. How efficient is this type of search?
- What is Binary Search? Explain Binary Search with C source code. Is this more efficient than Linear Search?
- What is Hash Table? Where it is used? Explain Hash Table with C source code.
- What are different types of sorting used in C programming?
- What is Bubble Sort? explain with an example
- What is Selection Sort? explain with an example
- What is Insertion Sort? explain with an example
- What is Quick Sort algorithm? explain with an example [C source code]
- What is Heap Sort? explain with an example
- What is Merge sort? explain with an example
- What is Radix Sort algorithm? explain with an example
OS shell parameter passing
- In main(int argc,char*argv) what is the meaning of argc and argv?
- Who calls main() function? What is C startup routine and assembly, explain?
- How does shell pass paramaters to my C program? [details of argv and environ]
- How to create a child process with C library call system() ?
- How to install cleanup handler during exit using atexit?
Library and DLLs
- How many types of Libraries are there in C?
- How static linking is done in C?
- What are the types of dynamic linking methods available?
- How implicit dynamic linking works in C? How to call a library function located in .SO or .DLL?
- What is explicit dynamic linking? How to load and call a SO/DLL function at runtime?
Interfacing with Java VB DLLs Libraries
Math Library functions
- What are the Arithmetic and math functions available in C?
- What are the trigonometric functions in math library?
File System handling
- How to open an existing file or create a new file?
- What is fdopen? How to reopen an existing file descriptor opened earlier with open/creat?
- What is the difference between write and append mode of fopen? Can I append a file without opening in append mode?
- How does mode of file operation differ in binary and text mode?
- What is binary mode of file operation and how to read/write in binary mode?
- How to seek to a position of a file? How to know current position? How to rewind position back to beginning?
- How to read/write files in formatted string mode?
- How to flush buffer in disk subsystem?
- How to know the presence of input buffer using poll and select?
- How to change blocking and non-blocking mode of file?
- How to handle Standard Input and output stream in char mode and string mode?
- How to handle formatted Standard Input and output stream?
Low level System Programming
- How to perform I/O control opertaions with a device file using ioctl()?
- How to map file buffer to memory using mmap?
- How to access I/O ports, MMIO registers and DOS interrupt services?
- How call BIOS and DOS system interrupt services with int86 and inline assembly?
- How to put sleep/delay in an program execution?
- How to make sound in PC Speaker?
Graphics and Mouse interfacing
- VGA programming in C under DOS/Turbo C Graphics- How to?
- Mouse programming in C - How to? (int33 enable, show/hide, get position, custom pointers)
Books & links
C Programming Language (Prentice Hall Software)
Let Us C Paperback - 2006 by Yashavant Kanetkar
Understanding and Using C Pointers Core techniques for memory management
Data Structures Using C and C++ Paperback - 1998
Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares