Introduction to C Flashcards

1
Q

What are key features of the C programming language?

A

Direct memory addressing

Low runtime overheads (no exception handling or garbage collection)

Small runtime size

Deterministic resource usage

Programmer-controlled memory usage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name some examples of C/C++ usage in the industry.

A

Linux and Windows kernels (C)

Android kernel (C)

Adobe Acrobat Reader (C++)

Oracle RDBMS (C, C++, Assembly)

Python’s CPython implementation (C)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you describe C’s programming paradigm and compilation type?

A

C is an imperative, procedural language that is compiled and statically, weakly typed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does a simple “Hello World” program look like in C?

A

include <stdio.h></stdio.h>

int main() {
printf(“Hello world!\n”);
return 0;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you compile a C program using GCC?

A

Use gcc myProgram.c -o myProgram. This compiles and links myProgram.c into an executable named myProgram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the two main stages in creating an executable from C source code?

A

Compilation: Translates source code into object code (*.o files).

Linking: Combines object code into an executable, resolving references like libraries and external functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some basic data types in C, their sizes, and ranges?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What constructs does C use for conditional execution?

A

if and else

switch statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What types of loops are available in C?

A

for loops
while loops
do-while loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you use printf to print formatted values?

A

%d for integers
%f for floats
%c for characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does it mean that C is weakly typed?

A

Variables must be declared with a type, but implicit type conversions are allowed, sometimes leading to precision loss.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is C considered a valuable programming language to learn?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

C is:

A

imperative
procedural/functional
compiled
statically, weakly typed
portable, ubitquitous
very fast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

statically typed

A

types are checked before runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

imperative

A

describes computation in terms of statements that change a program state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

declarative

A

describes computation in terms of what it should accomplish (e.g. SQL)

17
Q

C has/ C doesn’t have

A

has:
explicit memory management
ANSI/ISO standards

doesn’t have:
runtime error checking
sophisticated exception handling

18
Q

The C standards

A

Kernighan & Ritchie
ANSI
C99
C11
Embedded C