1/36
INCOMPLETE
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
“C is a middle-level programming language.”
Briefly explains what this means.
C combines features of low-level (memory, hardware access) & high-level (functions, modular code) programming languages.
“C is structured and modular.”
Briefly explains what this means.
C uses functions to divide programs into manageable blocks of code, which makes debugging reuse easier.
“C has efficient I/O (input/output).”
Briefly explains what this means.
scanf()
for direct access to input operations
printf()
for direct access to output operations
scanf()
uses ____________ input, which can affect…
scanf()
uses buffered input, which can affect how strings and newlines are handled.
You should always check return values from scanf()
to ensure….
You should always check return values from scanf()
to ensure…. input was correctly received.
Mismatching format specifiers (e.g., %d
for a float
) may cause ____________ behaviour.
Mismatching format specifiers (e.g., %d
for a float
) may cause undefined behaviour.
T or F: C is a case-sensitive language.
True
T or F: C treats Variable
and variable
as different identifiers.
True because C is case-sensitive
Every _________ in C must end with a semi-colon.
Every statement in C must end with a semi-colon.
Name 2 things curly braces are used for in C.
Used to define blocks of code, especially for if
, loops
, and functions
.
//Example
if (x > 0) {
printf("Positive\n");
x = x - 1;
}
(2) Helps group multiple statements.
//Example
#include <stdio.h>
int main() {
int x = 10;
if (x > 5) {
printf("x is greater than 5\n");
x = x - 1;
printf("x is now %d\n", x);
}
return 0;
}
//Without { }, only one statement would be part of the if.
//With { }, it groups multiple statements as one block under the if.
T or F: In C, a main() function is NOT mandatory.
False.
What are the two forms of main() function accepted in C?
//Opt 1
int main()
//Opt 2
void main() // non-standard, but accepted in many compilers
(a) Name the 3 categories of data types.
(b) Then name the main types within each category, their size, and their range.
(1) BASIC (PRIMARY)
Type | Size | Range |
---|---|---|
| 2 bytes | -32,768 to 32,767 |
| 1 byte | -128 to 127 |
| 4 bytes | ~±3.4 × 10⁻³⁸ to 10³⁸ |
| 8 bytes | ~±1.7 × 10⁻³⁰⁸ to 10³⁰⁸ |
(2) MODIFIED
Type | Size | Description |
---|---|---|
| 2 | 0 to 65,535 |
| 4 | Larger range than int |
| 2 | Smaller range |
| 1 | 0 to 255 |
(3) DERIVED
Arrays
Pointers
Structures
Unions
(a) What is a pointer?
(b) Syntax?
(a) A pointer is a variable that stores the memory address of another variable.
(b) Syntax:
//Syntax
int x = 10;
int *p = &x; // 'p' holds the address of x
Operator |
---|
|
What’s its meaning?
Operator | Meaning |
---|---|
| "Address of" operator |
Operator |
---|
|
What’s its meaning?
INCOMPLETE
In order to use a pointer, you must always..
Initialize the pointer before using it.
Uninitialized pointers can cause…
INCOMPLETE
Which types of statements in C govern the flow of execution?
🔹 if
, if-else
, and nested if-else
Describe what each is used for in 1 sentence:
(a) if
, if-else
, and nested if-else
(b) switch
Statement
(a) if
, if-else
, and nested if-else
Used to selectively execute code based on one or more Boolean conditions, with nested if-else
handling multiple layered decisions.
Example:
if (x > y) {
printf("x is greater");
} else {
printf("y is greater");
}
(b) switch
Statement
Used for multi-way branching, efficiently executing code based on the value of a single expression (usually an integer or enum).
Example:
printf("y is greater");
}
(c) while
Loop
Unknown number of iterations
Executes a block of code repeatedly as long as the condition is true, checking the condition before the first iteration.
(d) do-while
Loop
Executes a block of code at least once, and then continues looping while the condition remains true (condition is checked after the loop body).
A
(e) for
Loop
Describe what each is used for in 1 sentence. Then specify when the loop condition is evaluated — that is, whether the loop checks the condition before (entry) or after (exit) executing the loop body.
(a) while
Loop
(b) do-while
Loop
(c) for
Loop
Loop Type | Entry/Exit | Used For |
---|---|---|
| Entry | Unknown iterations (check before) |
| Exit | At least one iteration guaranteed |
| Entry | Count-controlled iterations |
Briefly what “Jump” statements do:
(a) break
(b) continue
🔹 Jump Statements
break
: Exit loop or switch
continue
: Skip to next iteration
&&
(a) Type of operator?
(b) Function
(a) Type: Logical operator
(b) Function:
Used to combine two Boolean conditions.
The result is true
(1) only if both conditions are true; otherwise, it evaluates to false
(0).
if (x > 0 && x < 10)
{
printf("x is between 1 and 9\n");
}