Introduction to C Flashcards
What are key features of the C programming language?
Direct memory addressing
Low runtime overheads (no exception handling or garbage collection)
Small runtime size
Deterministic resource usage
Programmer-controlled memory usage
Name some examples of C/C++ usage in the industry.
Linux and Windows kernels (C)
Android kernel (C)
Adobe Acrobat Reader (C++)
Oracle RDBMS (C, C++, Assembly)
Python’s CPython implementation (C)
How would you describe C’s programming paradigm and compilation type?
C is an imperative, procedural language that is compiled and statically, weakly typed.
What does a simple “Hello World” program look like in C?
include <stdio.h></stdio.h>
int main() {
printf(“Hello world!\n”);
return 0;
}
How do you compile a C program using GCC?
Use gcc myProgram.c -o myProgram. This compiles and links myProgram.c into an executable named myProgram
What are the two main stages in creating an executable from C source code?
Compilation: Translates source code into object code (*.o files).
Linking: Combines object code into an executable, resolving references like libraries and external functions.
What are some basic data types in C, their sizes, and ranges?
char: 1 byte, -128 to 127
int: 4 bytes, -2,147,483,648 to 2,147,483,647
float: 4 bytes, ~6-digit precision
double: 8 bytes, ~15-digit precision
What constructs does C use for conditional execution?
if and else
switch statements
What types of loops are available in C?
for loops
while loops
do-while loops
How do you use printf to print formatted values?
%d for integers
%f for floats
%c for characters
What does it mean that C is weakly typed?
Variables must be declared with a type, but implicit type conversions are allowed, sometimes leading to precision loss.
Why is C considered a valuable programming language to learn?
C is universal, efficient, close to the machine, widely available, and forms the foundation of many other languages. It is ideal for operating systems and embedded systems.
C is:
imperative
procedural/functional
compiled
statically, weakly typed
portable, ubitquitous
very fast
statically typed
types are checked before runtime
imperative
describes computation in terms of statements that change a program state
declarative
describes computation in terms of what it should accomplish (e.g. SQL)
C has/ C doesn’t have
has:
explicit memory management
ANSI/ISO standards
doesn’t have:
runtime error checking
sophisticated exception handling
The C standards
Kernighan & Ritchie
ANSI
C99
C11
Embedded C