What type of error occurs when you forget a semicolon at the end of a C statement?
Analysis & Theory
Missing a semicolon causes a syntax (compilation) error, which prevents the program from compiling.
What will this code cause?
```c
int x = 10 / 0;
```
C
Runtime error (division by zero)
Analysis & Theory
Division by zero causes a runtime error because it is undefined behavior.
What kind of error is caused by using an uninitialized pointer?
Analysis & Theory
Using an uninitialized pointer may lead to a segmentation fault at runtime.
What will happen if you access an array out of its bounds in C?
C
Runtime error or unexpected behavior
Analysis & Theory
Accessing out-of-bounds memory may cause a segmentation fault or logical bugs (undefined behavior).
What is a logical error?
B
An error that crashes the program
C
An error where the program compiles and runs but gives wrong results
D
An error that prevents compilation
Analysis & Theory
Logical errors produce incorrect results despite successful compilation and execution.
What will happen if you forget to include `#include <stdio.h>` in a program using `printf()`?
B
Compilation error: implicit declaration of function
Analysis & Theory
Using `printf()` without declaring it causes a compilation warning/error about implicit function declaration.
What kind of error is this?
```c
if (x = 5) {...}
```
Analysis & Theory
Using `=` instead of `==` is a **logical error**; it assigns instead of comparing.
Which error type occurs when you use an undeclared variable?
Analysis & Theory
Using undeclared variables causes a compilation error.
What does a segmentation fault indicate in C?
C
Illegal memory access at runtime
D
Correct program execution
Analysis & Theory
A segmentation fault means the program tried to access memory it shouldn't (e.g., invalid pointer access).
Which of the following can cause **undefined behavior** in C?
D
Declaring a global variable
Analysis & Theory
Accessing memory after it has been freed causes undefined behavior and must be avoided.