Learning Resources
Top 100 Interview Q&A
The Top 100 C interview questions and answers, covering every concept of the language — from basics and data types to pointers, dynamic memory, structures and unions, file handling, and the preprocessor.
C Interview Questions & Answers
The most frequently asked C interview questions, covering every concept of the language — basics and program structure, data types, operators, control flow, arrays and strings, functions, recursion and storage classes, pointers, dynamic memory, structures and unions, file handling, and the preprocessor. Each answer is written the way you should say it in an interview.
C Basics & Program Structure
Q1–Q9Q1 What is C and why is it called a middle-level language?
Answer C is a general-purpose, procedural, compiled programming language developed by Dennis Ritchie at Bell Labs in 1972. It is called middle-level because it combines high-level features (functions, structured control flow, readable syntax) with low-level capabilities (pointers, direct memory access, bitwise operators), so it can be used both for application programming and for systems programming such as operating systems and device drivers.
Q2 What are the main features of C?
Answer Simplicity with a small keyword set, portability across platforms, speed and efficiency, a rich set of operators, support for pointers and direct memory manipulation, modularity through functions, extensibility through user-defined types and libraries, structured programming, and recursion.
Q3 What is the structure of a C program?
Answer A C program typically consists of documentation (comments), preprocessor directives such as #include and #define, global declarations, the main() function, and one or more user-defined functions. Execution always begins at main() regardless of where it appears in the file.
Q4 What is the difference between a compiler and an interpreter?
Answer A compiler translates the entire program into machine code in one pass and reports all errors together, producing a separate executable that runs fast. An interpreter translates and executes the program line by line, stopping at the first error, which makes debugging easier but execution slower. C uses a compiler.
Q5 What are the stages of compilation in C?
Answer Four stages: preprocessing (expands macros and includes headers), compilation (translates the expanded source into assembly), assembly (converts assembly into object code), and linking (combines object files with library code to produce the final executable).
Q6 What is a token in C?
Answer A token is the smallest individual unit of a program that the compiler recognises. C has six kinds: keywords, identifiers, constants, string literals, operators, and special symbols such as braces and semicolons.
Q7 What are keywords and how many are there?
Answer Keywords are reserved words with predefined meanings that cannot be used as identifiers. C89 defines 32 keywords such as int, if, while, return, and struct. C99 added five more (inline, restrict, _Bool, _Complex, _Imaginary) and C11 added further underscore-prefixed keywords.
Q8 What are the rules for naming an identifier?
Answer An identifier may contain letters, digits, and underscores; it must not begin with a digit; it cannot be a keyword; it is case sensitive; and it must not contain spaces or special characters. Names beginning with an underscore followed by a capital letter are reserved for the implementation.
Q9 What is the difference between a declaration and a definition?
Answer A declaration introduces a name and its type to the compiler without allocating storage, as in extern int x; or a function prototype. A definition allocates storage or provides the body, as in int x; or a complete function. A name may be declared many times but defined only once.
Data Types, Variables & Constants
Q10–Q18Q10 What are the basic data types in C?
Answer The primary types are char, int, float, double, and void. These combine with the modifiers short, long, signed, and unsigned. C also has derived types (arrays, pointers, functions) and user-defined types (struct, union, enum, typedef).
Q11 What is the size of int, and is it fixed?
Answer It is not fixed by the standard. int is guaranteed to be at least 16 bits, but on most modern 32-bit and 64-bit systems it is 4 bytes. The standard only guarantees minimum ranges and that sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long). Always use sizeof rather than assuming.
Q12 What is the difference between float and double?
Answer float is single precision, typically 4 bytes with about 6–7 significant digits. double is double precision, typically 8 bytes with about 15–16 significant digits. Floating-point literals such as 3.14 are double by default; write 3.14f for a float.
Q13 What is the difference between signed and unsigned?
Answer A signed type can hold negative and positive values, splitting its range around zero. An unsigned type holds only non-negative values and therefore doubles the positive range. An 8-bit signed char holds −128 to 127 while an unsigned char holds 0 to 255. Unsigned arithmetic wraps around instead of overflowing.
Q14 What is the difference between const and #define?
Answer const is handled by the compiler, has a type, respects scope, and is visible in the debugger. #define is a preprocessor text substitution with no type, no scope, and no debugger presence. Prefer const or enum for constants.
Q15 What is a volatile variable?
Answer volatile tells the compiler that a variable may change outside the program flow — through hardware, an interrupt, or another thread — so it must not be cached in a register or optimised away. Every read must fetch from memory. It is essential for memory-mapped hardware registers.
Q16 Can a variable be both const and volatile?
Answer Yes. const volatile means the program itself must not modify it, but something external can. A read-only hardware status register is the classic example: your code may only read it, yet its value changes on its own.
Q17 What is type casting and what is the difference between implicit and explicit?
Answer Type casting converts a value from one type to another. Implicit conversion (type promotion) is done automatically by the compiler, as when an int is used in a float expression. Explicit casting is written by the programmer, as in (float)a / b, and is required when you want to override the default behaviour.
Q18 Why does 5 / 2 give 2 in C?
Answer Both operands are integers, so integer division is performed and the fractional part is discarded. To get 2.5, make at least one operand floating point: 5.0 / 2, or cast one operand as in (float)5 / 2.
Operators & Expressions
Q19–Q27Q19 What is the difference between ++i and i++?
Answer Both increment i by one. Pre-increment ++i increments first and yields the new value; post-increment i++ yields the old value and increments afterwards. If i is 5, then j = ++i sets both to 6, while j = i++ sets j to 5 and i to 6.
Q20 What is the difference between = and ==?
Answer = is the assignment operator, which stores a value in a variable. == is the equality operator, which compares two values and yields 1 or 0. Writing if (x = 5) assigns 5 and is always true, which is a very common bug.
Q21 What is the difference between & and &&?
Answer & is the bitwise AND, which operates on individual bits of its operands. && is the logical AND, which yields 1 or 0 and short-circuits: if the left operand is false, the right one is never evaluated.
Q22 What is short-circuit evaluation?
Answer For && the right operand is skipped when the left is false; for || it is skipped when the left is true, because the result is already determined. This is why if (p != NULL && p->x) is safe — the dereference never runs when p is NULL.
Q23 What is the sizeof operator, and is it a function?
Answer sizeof is a compile-time unary operator, not a function, that yields the size in bytes of a type or expression as a size_t. Because it is evaluated at compile time, the expression inside it is not executed: sizeof(i++) does not increment i.
Q24 What is the ternary operator?
Answer The conditional operator condition ? expr1 : expr2 is the only ternary operator in C. It evaluates the condition and yields expr1 if true and expr2 otherwise, providing a compact alternative to a short if-else.
Q25 What is operator precedence and associativity?
Answer Precedence decides which operator binds first when several appear in one expression, so 2 + 3 * 4 is 14. Associativity decides the order among operators of equal precedence: most are left to right, while assignment and unary operators are right to left. Parentheses override both.
Q26 What do the bitwise operators do?
Answer & is AND, | is OR, ^ is XOR, ~ is one's complement, << is left shift, and >> is right shift. Left shifting by n multiplies by 2^n and right shifting divides by 2^n for non-negative values. They are used for flags, masks, and low-level optimisation.
Q27 What is undefined behaviour in expressions like i = i++ + ++i?
Answer Modifying the same object more than once between sequence points is undefined behaviour. The compiler may produce any result, and different compilers legitimately produce different answers. Such expressions should never be written.
Control Flow
Q28–Q34Q28 What is the difference between if-else and switch?
Answer if-else can test any condition including ranges and floating-point comparisons, and it evaluates conditions one by one. switch tests one integral expression against constant case labels and can compile into a jump table, making it faster and more readable for many discrete values.
Q29 Why is break needed in a switch?
Answer Without break, execution falls through into the following cases. Sometimes that is intentional — grouping several labels for the same action — but usually the missing break is a bug that causes several blocks to run.
Q30 Can a switch use float or string cases?
Answer No. The switch expression and case labels must be integral, meaning int, char, or enum. Floating-point values and strings are not allowed; use if-else with strcmp for strings.
Q31 What is the difference between while and do-while?
Answer while is entry controlled: the condition is tested before the body, so the body may run zero times. do-while is exit controlled: the body runs once before the condition is tested, so it always executes at least once. Note that do-while requires a semicolon after the condition.
Q32 What is the difference between break and continue?
Answer break exits the innermost loop or switch entirely. continue skips the rest of the current iteration and jumps to the next one — in a for loop the update expression still runs, but in a while loop you must make sure the update is not skipped, or you get an infinite loop.
Q33 What is an infinite loop and how do you write one?
Answer A loop whose condition never becomes false. Common forms are for(;;), while(1), and do { } while(1). They are used deliberately in event loops and embedded firmware, with break used to exit on a condition.
Q34 What does the goto statement do and should you use it?
Answer goto transfers control unconditionally to a label within the same function. It is discouraged because it makes control flow hard to follow, but one accepted use is jumping to a single cleanup block when an error occurs deep inside nested code.
Arrays & Strings
Q35–Q44Q35 What is an array and why does indexing start at 0?
Answer An array is a contiguous block of memory holding elements of the same type under one name. Indexing starts at 0 because the index is an offset from the base address: a[i] is defined as *(a + i), so the first element sits at offset 0.
Q36 What happens if you access an array out of bounds?
Answer C performs no bounds checking, so the behaviour is undefined. You may read garbage, silently corrupt other variables, or crash with a segmentation fault. The absence of checking is a source of speed and of security vulnerabilities.
Q37 How is a 2D array stored in memory?
Answer In row-major order: all of row 0 is stored, then all of row 1, and so on, in one contiguous block. The address of a[i][j] is base + (i * columns + j) * sizeof(element). Traversing row by row is therefore faster than column by column because of cache locality.
Q38 What is array decay?
Answer In most expressions an array name converts automatically to a pointer to its first element. That is why a function parameter written as int a[] is really int *a, and why sizeof inside the function gives the pointer size rather than the array size. The exceptions are sizeof, &, and a string literal used to initialise an array.
Q39 What is a string in C?
Answer A string is a one-dimensional array of char terminated by the null character '\0'. There is no separate string type. The terminator is what lets library functions find the end, so "hello" occupies 6 bytes, not 5.
Q40 What is the difference between strlen and sizeof for a string?
Answer strlen is a runtime function that counts characters up to but not including the null terminator. sizeof is a compile-time operator giving the total allocated bytes. For char s[10] = "hi", strlen(s) is 2 and sizeof(s) is 10.
Q41 What is the difference between char s[] = "hi" and char *s = "hi"?
Answer The array form copies the characters into a modifiable array owned by the variable. The pointer form points at a string literal, which is typically stored in read-only memory; attempting to modify it is undefined behaviour and usually crashes.
Q42 Why is gets() dangerous, and what should you use instead?
Answer gets() has no way to know the size of the destination buffer, so any long input overflows it. It was deprecated in C99 and removed in C11. Use fgets(buf, sizeof buf, stdin), which takes a size limit, and then strip the trailing newline it stores.
Q43 How do you compare two strings?
Answer With strcmp(s1, s2), which returns a negative value, zero, or a positive value depending on lexicographic order. You cannot use == because that compares the two pointers, not the characters they point at.
Q44 What is an array of strings?
Answer Either a 2D char array such as char names[3][20], which allocates equal fixed-size rows and is modifiable, or an array of pointers such as char *names[3], which stores addresses of string literals, uses memory proportionally, and points at read-only data.
Functions, Recursion & Storage Classes
Q45–Q54Q45 What is a function prototype and why is it needed?
Answer A prototype declares the function name, return type, and parameter types before the function is used. It lets the compiler check the number and types of arguments and apply correct conversions. Without it, the compiler must guess, which leads to silent errors.
Q46 What is the difference between call by value and call by reference?
Answer Call by value copies the argument, so changes inside the function do not affect the caller. C is always call by value; "call by reference" is simulated by passing an address, so the function can modify the original through the pointer.
Q47 What is recursion, and what does every recursive function need?
Answer Recursion is a function calling itself to solve smaller instances of a problem. Every recursive function needs a base case that stops the recursion and a recursive case that moves towards it. Without a reachable base case you get infinite recursion and a stack overflow.
Q48 What is the difference between head recursion and tail recursion?
Answer In head recursion the recursive call happens before the other work, so processing occurs while the calls unwind. In tail recursion the recursive call is the last operation, so nothing remains to be done after it returns — which allows some compilers to optimise it into a loop.
Q49 What is the difference between recursion and iteration?
Answer Recursion expresses a problem in terms of itself, uses the call stack, and costs extra memory and call overhead, but reads naturally for trees and divide-and-conquer problems. Iteration uses loops, needs constant extra memory, and is generally faster. Any recursion can be rewritten iteratively.
Q50 What are the four storage classes in C?
Answer auto is the default for local variables, stored on the stack with block scope and automatic lifetime. register is a hint to keep the variable in a CPU register, and its address cannot be taken. static keeps the value between calls and limits a global to its file. extern declares a variable or function defined in another file.
Q51 What does static mean for a local variable and for a global one?
Answer For a local variable it changes the lifetime: the variable is created once, initialised to zero, and retains its value between calls, while keeping block scope. For a global variable or function it changes the linkage: the name becomes private to its translation unit and is invisible to other files.
Q52 What is the difference between scope and lifetime?
Answer Scope is where in the code a name is visible — block, function, file, or program. Lifetime is how long the storage exists at runtime — automatic, static, or dynamic. A static local variable shows they are independent: small scope, whole-program lifetime.
Q53 Where are local variables, global variables, and dynamic memory stored?
Answer Local variables and function parameters live on the stack. Initialised globals and static variables live in the data segment, uninitialised ones in BSS where they are zeroed. Dynamically allocated memory lives on the heap. Code lives in the text segment.
Q54 What is a function pointer and where is it used?
Answer A function pointer stores the address of a function, declared as int (*fp)(int, int). It is used for callbacks, for passing a comparison function to qsort, for dispatch tables that replace long switch statements, and for plug-in style designs.
Pointers
Q55–Q64Q55 What is a pointer?
Answer A pointer is a variable that stores the memory address of another object. It is declared with a type, as in int *p, which tells the compiler how to interpret the bytes at that address and how far to move in pointer arithmetic.
Q56 What is a NULL pointer?
Answer A pointer that is guaranteed not to point at any valid object, written as NULL. It is used to mark "no target yet" and is what malloc returns on failure. Dereferencing it is undefined behaviour and usually causes a segmentation fault.
Q57 What is a void pointer?
Answer A generic pointer that can hold the address of any object type. It cannot be dereferenced directly and cannot take part in pointer arithmetic without a cast, because the compiler does not know the size of the target. malloc returns void *.
Q58 What is a dangling pointer?
Answer A pointer that still holds an address after the memory there has been freed or has gone out of scope. Using it is undefined behaviour. Avoid it by setting the pointer to NULL immediately after free and never returning the address of a local variable.
Q59 What is a wild pointer?
Answer An uninitialised pointer holding whatever garbage was in its memory. Dereferencing it can corrupt arbitrary memory. Always initialise pointers, to NULL if nothing else.
Q60 What is pointer arithmetic and how is it scaled?
Answer Adding an integer to a pointer moves it by that many elements, not bytes: for an int pointer, p + 1 advances by sizeof(int) bytes. Subtracting two pointers into the same array yields the number of elements between them. Only addition, subtraction, comparison, and increment/decrement are allowed.
Q61 What is a pointer to a pointer?
Answer A pointer holding the address of another pointer, declared as int **pp. It is used to modify a caller's pointer inside a function, to build dynamic 2D arrays as an array of row pointers, and in the argv parameter of main.
Q62 What is the difference between const char *p and char * const p?
Answer const char *p is a pointer to a constant character: you cannot change *p but you can change p. char * const p is a constant pointer to a character: you can change *p but not p. Read the declaration right to left from the variable name.
Q63 What is the difference between an array and a pointer?
Answer An array is a block of memory whose name is not a modifiable object; a pointer is a variable holding an address and can be reassigned. sizeof gives the whole array size but only the pointer size for a pointer. They look similar because an array decays to a pointer in most expressions.
Q64 Why does a function receiving an array not know its size?
Answer Because the array decays to a pointer at the call, and a pointer carries no length information. sizeof inside the function measures the pointer. Always pass the element count as a separate parameter.
Dynamic Memory Management
Q65–Q71Q65 What is the difference between static and dynamic memory allocation?
Answer Static allocation happens at compile time with a fixed size on the stack or data segment and is freed automatically. Dynamic allocation happens at runtime on the heap with a size that can depend on input, must be freed explicitly with free, and can be resized with realloc.
Q66 What is the difference between malloc and calloc?
Answer malloc(n) takes one argument, the total byte count, and leaves the memory uninitialised. calloc(n, size) takes the element count and element size, and zero-initialises the block. calloc is slightly slower but safer when you need a clean start.
Q67 What does realloc do?
Answer It resizes an existing block, preserving the contents up to the smaller of the old and new sizes, and may move the block to a new address. Always assign the result to a temporary pointer first, because realloc returns NULL on failure and assigning directly would leak the original block.
Q68 What happens if you call free twice on the same pointer?
Answer Double free is undefined behaviour and typically corrupts the heap or aborts the program. Setting the pointer to NULL after freeing prevents it, since free(NULL) is defined to do nothing.
Q69 What is a memory leak and how do you avoid it?
Answer A memory leak is allocated memory that is never freed and can no longer be reached because the pointer to it was lost or overwritten. Avoid it by pairing every malloc with a free, freeing on every exit path including error paths, and checking with a tool such as Valgrind.
Q70 How do you create a dynamic 2D array?
Answer Either allocate an array of row pointers and then each row separately, which allows ragged rows but scatters memory, or allocate one contiguous block of rows*cols elements and index it manually as a[i*cols + j], which is cache friendly and needs a single free.
Q71 What is the difference between the stack and the heap?
Answer The stack is managed automatically, is fast, has limited size, and holds local variables and call frames in last-in-first-out order. The heap is managed manually through malloc and free, is larger, slightly slower, can fragment, and holds data whose lifetime you control.
Structures, Unions & Enums
Q72–Q80Q72 What is the difference between a structure and a union?
Answer A structure gives every member its own memory, so its size is at least the sum of the members plus padding and all members are valid at once. A union shares one memory location among all members, so its size is that of the largest member and only the most recently written member is meaningful.
Q73 Why is sizeof a structure sometimes larger than the sum of its members?
Answer Because of padding. The compiler inserts unused bytes so that each member starts at an address suitable for its alignment, and pads the end so arrays of the structure stay aligned. Ordering members from largest to smallest usually reduces the waste.
Q74 Can you compare two structures with ==?
Answer No. C provides no structure comparison because padding bytes hold indeterminate values. Compare member by member, or use memcmp only when you are certain the padding was zeroed.
Q75 What is the difference between the . and -> operators?
Answer The dot accesses a member of a structure variable; the arrow accesses a member through a pointer to a structure. p->x is shorthand for (*p).x, and the parentheses are required because the dot binds tighter than the dereference.
Q76 What is a self-referential structure?
Answer A structure containing a pointer to its own type, as in struct Node { int data; struct Node *next; };. It cannot contain an instance of itself because that would require infinite size. Self-referential structures are the basis of linked lists, trees, and graphs.
Q77 What is a bit field?
Answer A structure member declared with an explicit width in bits, as in unsigned int flag : 1;. Bit fields pack several small values into few bytes. You cannot take their address, they cannot form arrays, and their memory layout is implementation-defined, so they are not portable for hardware or file formats.
Q78 What is an enum and how are its values assigned?
Answer An enum defines a set of named integer constants. Values start at 0 and increase by 1 unless assigned explicitly, and members after an assignment continue from it. The constants are of type int, duplicates are allowed, and no range checking is performed.
Q79 What is the difference between typedef and #define for types?
Answer typedef is processed by the compiler, creates a true type alias, and respects scope. #define is a text substitution. The classic difference: with typedef char *P; the line P a, b; makes both pointers, while with #define P char * it expands to char *a, b; and only a is a pointer.
Q80 How do you pass a large structure to a function efficiently?
Answer Pass a const pointer: void f(const struct T *p). Passing by value copies the entire structure, which is expensive for large records, while a pointer passes only an address and const documents and enforces that the function will not modify it.
File Handling & Command Line
Q81–Q88Q81 What is a FILE pointer?
Answer FILE is an opaque structure holding the buffer, current position, and error flags for a stream. You never use FILE directly; fopen returns a FILE * that identifies the stream in every subsequent call.
Q82 What are the file opening modes?
Answer "r" reads an existing file, "w" creates or truncates for writing, "a" appends, and "r+", "w+", "a+" add read-write capability with the same creation and truncation rules. Adding b, as in "rb", selects binary mode with no newline translation.
Q83 What is the difference between a text file and a binary file?
Answer A text file stores human-readable characters and, on Windows, translates \n to \r\n. A binary file stores raw bytes exactly as they appear in memory, so numbers occupy their native size and no translation occurs. Text is portable; binary is compact and supports fixed-size random access.
Q84 Why is while (!feof(fp)) wrong?
Answer feof only becomes true after a read has already failed, so the loop runs one extra time and processes the last item twice. Test the read function itself: while (fgets(...) != NULL) or while (fscanf(...) == 1).
Q85 Why must fgetc be assigned to an int rather than a char?
Answer fgetc returns every possible byte value plus the distinct value EOF, usually −1. A char cannot represent all of those distinctly, so the comparison with EOF can fail or a valid byte can be mistaken for EOF.
Q86 What do fseek, ftell, and rewind do?
Answer fseek moves the file position by an offset from SEEK_SET, SEEK_CUR, or SEEK_END. ftell reports the current offset, which is how you find a file size. rewind returns to the beginning and clears the error flags.
Q87 What are argc and argv?
Answer They are the parameters of main(int argc, char *argv[]). argc is the number of command line arguments including the program name, so it is always at least 1. argv is an array of strings where argv[0] is the program name and argv[argc] is NULL. All arguments are strings and must be converted if you need numbers.
Q88 Why is fflush(stdin) wrong?
Answer fflush is defined only for output streams; calling it on an input stream is undefined behaviour even though it appears in older textbooks. To discard leftover input, read and discard characters until a newline or EOF.
Preprocessor & Miscellaneous
Q89–Q100Q89 What is the preprocessor and when does it run?
Answer The preprocessor is a text-processing stage that runs before compilation. It expands macros, includes header files, and removes code excluded by conditional directives, producing a translation unit that the compiler then reads. It understands no C syntax, types, or scope.
Q90 What is the difference between a macro and a function?
Answer A macro is expanded by the preprocessor as text, so there is no call overhead, no type checking, and arguments may be evaluated several times. A function is compiled once, type checked, evaluates arguments exactly once, appears in the debugger, and can recurse.
Q91 Why must macro parameters be wrapped in parentheses?
Answer Because the substitution is textual. #define SQ(x) x*x makes SQ(2+3) expand to 2+3*2+3, which is 11. Writing ((x)*(x)) — parenthesising both the parameters and the whole body — gives the expected 25.
Q92 What is conditional compilation and why use it?
Answer Directives such as #if, #ifdef, #ifndef, #elif, #else, and #endif include or exclude code before compilation. It is used for debug builds, cross-platform code, feature toggles, and include guards. Excluded code never reaches the compiler, so it costs nothing at runtime.
Q93 What is an include guard?
Answer The #ifndef NAME / #define NAME / #endif pattern that prevents a header from being pasted more than once into the same translation unit, which would cause redefinition errors. #pragma once does the same in one line but is a compiler extension rather than standard C.
Q94 What do the # and ## preprocessor operators do?
Answer # stringizes a macro argument, turning it into a string literal, so #x becomes "x". ## pastes two tokens into a single new token, so a##b becomes ab. They are used for logging that prints variable names and for generating related identifiers.
Q95 What are the common predefined macros?
Answer __FILE__ gives the source file name, __LINE__ the line number, __DATE__ and __TIME__ the compilation date and time, and __STDC__ indicates a conforming compiler. __func__ gives the current function name and is a predefined identifier rather than a macro. They are mostly used in logging and assertions.
Q96 What is a variadic macro?
Answer A macro taking a variable number of arguments, declared with ... and expanded through __VA_ARGS__. It is used mainly for logging wrappers around printf. GCC's ##__VA_ARGS__ and C23's __VA_OPT__ handle the case of an empty argument list.
Q97 What is the difference between #ifdef FLAG and #if FLAG?
Answer #ifdef tests only whether the name is defined, so it succeeds even for #define FLAG 0. #if evaluates the value, so it fails for 0. Choose based on whether existence or value is what matters.
Q98 What is the difference between exit() and return in main?
Answer In main they are effectively equivalent: both terminate the program with the given status. exit() can be called from any function and immediately ends the program after flushing streams and running functions registered with atexit, whereas return only leaves the current function.
Q99 What is undefined, unspecified, and implementation-defined behaviour?
Answer Undefined behaviour means the standard imposes no requirements at all, as with out-of-bounds access — anything may happen. Unspecified behaviour means several outcomes are valid and the compiler need not document its choice, such as argument evaluation order. Implementation-defined behaviour means the compiler must choose and document, such as the size of int.
Q100 What are the most common causes of a segmentation fault?
Answer Dereferencing a NULL, wild, or dangling pointer; writing past the end of an array or buffer; using a pointer after free; infinite recursion exhausting the stack; and writing to a string literal. Each is a case of touching memory the program does not own.