Karnataka KSEAB SSLC JTS Programming in ANSI C flashcards
Karnataka KSEAB SSLC JTS Programming in ANSI C · Build recall with a focused review session.
34 cards. Read the term and the definition here. The deck at the top of this page is optional.
- Token
- The smallest meaningful unit of a C program. The six classes are keywords, identifiers, constants, string literals, operators, and separators such as semicolons and braces.
- Identifier rules
- A name must start with a letter or underscore and contain only letters, digits, or underscores. It is case-sensitive and cannot be a keyword.
- sizeof operator
- A compile-time unary operator that returns the size of a type or object in bytes as type size_t. It does not evaluate its operand when applied to a type.
- const qualifier
- Marks an object as read-only after initialization. Attempting to modify it through that name is a compile-time error; it is not a compile-time constant for array sizes in C89.
- Integer division truncation
- When both operands of / are integers, the fractional part is discarded and the result truncates toward zero. The % operator gives the remainder with the dividend's sign.
- Short-circuit evaluation
- The && and || operators evaluate the left operand first and skip the right operand when the result is already known. This is used to guard null-pointer checks.
- Left shift operator
- The expression a << n shifts the bits of a left by n positions, filling with zeros. For non-negative values it multiplies by 2 to the power n.
- Cast expression
- A cast such as (float) a converts a value to the named type explicitly. It is used to force floating-point division or to narrow a value deliberately.
- switch fall-through
- When a case has no break statement, execution continues into the next case. Fall-through is sometimes intentional for grouping labels but is a common bug source.
- do-while loop
- A loop that executes its body once before testing the condition, so the body always runs at least once. A semicolon follows the closing while condition.
- break versus continue
- break exits the innermost loop or switch immediately. continue skips the rest of the current iteration and proceeds to the next condition test or loop update.
- for loop execution order
- The initialization runs once, the condition is tested before each iteration, the body executes, and the update expression runs after each iteration before the next test.
- Function prototype
- A declaration that gives a function's return type, name, and parameter types, letting the compiler check argument counts and types at each call site before the definition.
- Pass by value
- C passes arguments by copying their values into parameters. To let a function modify a caller's variable, pass its address and dereference the pointer inside the function.
- Static local variable
- A variable declared static inside a function keeps its value between calls. It is initialized only once, before the first call, and has program lifetime.
- Recursion base case
- The condition that stops a recursive function from calling itself again. Every recursive function needs at least one base case, or it recurses until the stack overflows.
- Array index range
- An array of n elements is valid at indices 0 through n-1. C does not check bounds, so an out-of-range index is undefined behavior, not a compile error.
- String terminator
- Every C string is a char array ending in the null character '\0'. String functions locate the end by scanning for this terminator, which is not counted in strlen.
- strcmp return value
- Compares two strings character by character and returns a negative value, zero, or a positive value as the first string is less than, equal to, or greater than the second.
- Row-major storage
- A two-dimensional array is stored row by row: all elements of row 0 come first, then row 1, and so on. The last index varies fastest in memory.
- Pointer declaration
- The form int *p; declares p as a pointer to int. The asterisk binds to the variable name, so int *a, b; declares one pointer and one int.
- Pointer arithmetic unit
- Adding 1 to a pointer advances it by the size of the pointed-to type in bytes. Subtracting two pointers into the same array yields the number of elements between them.
- malloc and free
- malloc(size) returns a pointer to uninitialized heap memory or NULL on failure. free releases the block; every successful allocation needs exactly one matching free.
- Arrow operator
- For a pointer to a structure, p->member accesses the member. It is shorthand for (*p).member and is used with pointers to structs passed to functions.
- Union storage
- A union lets several members share the same memory area. Its size is at least that of its largest member, and only one member holds a valid value at a time.
- typedef purpose
- typedef creates a new name (alias) for an existing type, such as typedef struct Node Node;. It does not create a new type, only a convenient synonym.
- Enum constants
- An enumeration declares named integer constants. The first is 0 by default, and each following one is one greater unless an explicit value is given.
- scanf return value
- scanf returns the number of input items successfully assigned, or EOF if input ends before any conversion. Checking this value detects malformed input.
- fopen modes
- Text modes are r (read), w (write, truncates), and a (append). Adding + allows both reading and writing; adding b opens the file in binary mode.
- fgets versus scanf
- fgets(buf, size, stdin) reads at most size-1 characters including spaces and stops at a newline, making it safer than scanf with %s for line input.
- Object-like macro
- A #define without parameters, such as #define MAX 100. The preprocessor replaces every later occurrence of the name with the token sequence before compilation begins.
- Include guard
- A pattern using #ifndef, #define, and #endif around a header's contents so that including the same header twice does not cause duplicate definitions.
- Compilation stages
- Preprocessing expands directives, compilation produces assembly, assembly produces object code, and linking combines object files with library code into an executable.
- Flowchart decision symbol
- A diamond shape represents a decision with one input and two labeled outputs, typically yes and no. Loops are drawn with an arrow returning to an earlier step.