CS2: SLP

0.0(0)
Studied by 2 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/27

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:52 AM on 5/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

28 Terms

1
New cards

Core rules of C

  • All data has a place (somewhere in memory)

  • All data has a size (sizeof tells byte size)

  • Zero is special (end of strings and NULL)

2
New cards

built in versions of zero

  • ‘\0’ for char

  • 0 for int

3
New cards

Differences of Java and C

  • Java is memory-managed, C is not

  • Java is object-oriented and strongly types, C is not

  • Java has built-in dynamic data structures, C does not

4
New cards

What ‘C programming is procedural’ means

  • No classes or objects

  • use of Global and local variables

  • No exceptions but uses error codes

  • has small, well-defined functions

5
New cards

Memory management

When the system manages your dynamically-allocated memory

6
New cards

Advantages of memory management

  • Few details for programmer

  • Code focuses on problem not allocation

  • reduced risk of memory-related security issues

7
New cards

Disadvantages of memory management

  • Less control and knowledge of what your program is doing

  • difficult to identify performance issues by studying code

  • difficult accessing hardware-specific low-level memory and registers

8
New cards

Characteristics of interpreted languages

  • Runs within virtual machine providing standard environment

  • Cross-platform compatible

  • greater overhead therefore worse performance

9
New cards

Characteristics of compiled languages

  • Native hardware instructions and conventions

  • needs compilation for different platforms

  • less overhead therefore better performance

10
New cards

Undefined behaviour

Behaviour, upon use of a nonportable or erroneous program construct or of erroneous data, for which this international standard imposes no requirements

11
New cards

Low-level and high-level languages

  • High level language abstracts more details that are irrelevant to the problem

  • Low level language requires programs to pay attention to irrelevant details

12
New cards

Static memory

Where memory allocation size is known at compile-time

13
New cards

Dynamic memory

Where memory allocation size is not known at compile-time

14
New cards

Places in which data must be located

  • The stack

  • The heap

  • The data segment

15
New cards

The stack

Read-write, created/destroyed with function calls. Requires size known at compile-time

16
New cards

The heap

read-write, allocated from OS via syscall. Can handle size unknown at compile-time

17
New cards

The data segment

read-only, stores literals and constants within the process

18
New cards

Data sizes in C

  • char: 1 byte

  • short: 2 bytes

  • int: 4 bytes

  • float: 4 bytes

  • long: 8 bytes

  • double: 8 bytes

19
New cards

Arrays in C

  • Laid out sequentially in memory

  • can be static or dynamic

  • they use pointer arithmetic

20
New cards

Decaying an array into a pointer

This is when a static array is passed to a function. the pointer to the starting element is passed and not the array as a whole

21
New cards

C compilation process

  1. Preprocessing

  2. Compilation

  3. Assembly

  4. Linking

22
New cards

Preprocessing

Prepares the raw code by removing comments, expanding macros and copying in header files.

  • Input: source code .c

  • output: expanded source code .i

23
New cards

Compilation

Checks the expanded code for syntax errors and translates high-level C logic into low-level instructions

  • input: expanded source code .i

  • output: assembly code .s

24
New cards

Assembly

Assembler translates human-readable instructions into raw, binary machine code the CPU understands

  • Input: assembly code .s

  • output: object code .o or .obj

25
New cards

Linking

Combines generated object code with external libraries and other object files to build final program

  • input: object code .o + external libraries

  • output: .exe or a.out

26
New cards

Declarations and Definitions

  • Declaration of something indicates its name and type

  • Definition of something indicates its name and type and reserves memory for it

27
New cards

When to use a Struct

This structure is used when you need to group related pieces of data that must all be stored maintained, and accessed simultaneously

28
New cards

When to use a Union

This is a structure used to conserve memory when having a variable that may be one of several types