Which of the following best describes the main purpose of the C programming language?
Think about what kind of programs need direct hardware access and efficiency.
C is a low-level language that provides control over hardware and memory, making it ideal for system programming and embedded systems.
What is the output of the following C program?
#include <stdio.h> int main() { int a = 5, b = 3; printf("%d\n", a + b); return 0; }
Remember that the + operator adds numbers, not concatenates them.
The program adds 5 and 3, printing 8.
What will this C program print?
#include <stdio.h> int main() { int x = 10; int *p = &x; *p = 20; printf("%d\n", x); return 0; }
Changing the value pointed to by p changes x.
The pointer p points to x, so *p = 20 changes x to 20.
What error will this C code produce?
#include <stdio.h> int main() { int arr[3] = {1, 2, 3}; printf("%d\n", arr[3]); return 0; }
Array indices start at 0 and go up to size-1.
Accessing arr[3] is out of bounds and causes undefined behavior.
Which reason best explains why C is called a portable programming language?
Think about how code moves between different computers.
C is portable because many compilers exist for different systems, so source code can be recompiled on each platform.