progweek2 Flashcards

(74 cards)

1
Q

the program starts to be executed with which function?

A

main()

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

Everytime program control encounters a function name, this function
will be _

A

called or invoked.

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

explain: The arguments are passed ”called-by-value”.

A

This means that each argument is evaluated, and the value is used locally for the corresponding formal parameter. The value is copied into the local variable.

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

If a variable is passed to a function by value, the original value of the
variable will (or will not) be changed?

A

not

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

What is scope?

A

It refers to the area where a function or variable is visible and
accessible to other codes.

”Identifiers are accessible only within the block in which they are
declared”

Be aware that the same identifier can be used in different declarations.

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

Parallel blocks are _

A

blocks defined at the same level.

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

text files:

A

It is a file that contains ASCII characters, used to store a stream of
characters.

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

key points of text files:

1
2
3
4

A
  1. Text files have no format, they are plain characters,
    whitespaces and line breaks.
  2. Each line in a text file ends with \n
  3. Example are files with .txt extension.
  4. They are a general and standard type to share information since they can be read or written by any text editor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The basic file operations that we can perform in C are:

A

Creating a new file

Opening an existing file

Reading from a file

Writing to a file

Moving to a specific location in a file

Closing a file

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

Creating a new file;

A

fopen() in mode ”a”/”a+” or ”w”/”w+”

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

Opening an existing file;

A

fopen()

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

Reading from a file;

A

fscanf() or fgets()

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

Writing to a file;

A

fprintf() or fputs()

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

Moving to a specific location in a file;

A

fseek()

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

Closing a file;

A

fclose()

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

A file pointer is

A

a reference to a
particular position in the opened file.
It is used in file handling to perform all file operations.

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

In C, we make use of the _ macro to declare the file pointer. The
macro is already define inside the _ header file.

A

FILE

stdio.h

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

calloc and malloc in which library?

A

stdlib.h

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

CPU :

A

(Central Processing Unit): The brain of the computer where most calculations take place

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

ALU :

A

(Arithmetic Logic Unit): Performs arithmetic and logic operations.

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

Control Unit:

A

Directs operations within the CPU, coordinating how data moves through it.

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

General Registers:

A

Small storage locations within the CPU that hold data temporarily during execution.

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

Memory:

A

Stores data and instructions that the CPU can quickly access. It is typically volatile, meaning it loses its contents when power is turned off.

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

Disc:

A

Refers to the storage devices like hard drives or SSDs that provide non-volatile storage, meaning they retain data when powered off.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
MMU :
(Memory Management Unit): A hardware component responsible for handling virtual and physical address translations.
26
BUS:
A communication system that transfers data between components inside a computer, or between computers.
27
what are the Other I/O Devices:
Monitor Keyboard Mouse Printer
28
physical memory:
any physical support that can be used to store data. The physical memory of modern computer is organized in a hierarchy (from fast-small to slow-big).
29
Registers:
Is space that is on the CPU and is the working memory that allows the processor to do basic operations.
30
Cache(s):
Is on the same chip of the CPU or very close to it, and is therefore usually very small but also very fast.
31
Primary Memory (RAM):
Is on a separate component, medium size, slower than cache memory.
32
Secondary Memory (Disks):
Your hard drive, it is usually very large, but also much slower than cache and RAM.
33
Instead of dealing with the physical memory programmers work on _. This means that __.
virtual memory they can assume that there is only one memory unit consisting of an array of contiguous memory cells as big as the programs need (max 4 GB for 32-bit systems).
34
Stack:
Portion of memory managed by the runtime support of C.
35
Heap:
Portion of memory managed by the programmer.
36
Static:
Portion of memory that contains external (global) variables, the code, constant values and any static data.
37
Runtime support :
is a collection of system software services that enable the execution of programs, managing necessary tasks like memory allocation and input/output operations behind the scenes.
38
Stacks :
are arrays of data managed with a LIFO (Last in, first out) policy. The stack is where all the local variables of our program are stored.
39
When we call a function in C: 1. The _ of the CPU and other information needed to restore the current state of the program is pushed. 2. The _ is pushed. 3. The _ are pushed and the values of the actual parameters are copied (pass-by-value). 4. Then _ are pushed. 5. When we exit the function all the previous information is _. 6. This information is usually called _.
1. current state 2. address of where the return value should be stored 3. formal parameters 4. local variables 5. popped and used to restore the correct status of the caller 6. activation record of the function
40
Pointers are :
variables that store the memory addresses of other variables, allowing direct access and manipulation of the memory allocated to those variables in a C program.
41
If x is a variable then &x denotes _ of x.
the address
42
If x is of type T , then &x is of type _, e.g., if x is an integer then &x is of type _.
T * int* integer pointer
43
One can therefore declare variables that are pointers to a type, e.g., int * p; declares _. We can therefore initialize it using _
a pointer to an integer p = &x
44
To access the content of the cell whose address is p we can use the __ operator, i.e., if x is 1 and p is &x then _ is 1.
* *p
45
_ is a special value that is used for empty pointers (pointers to nothing).
NULL
46
Pointers allow to implement a different type of parameter passing called _.
call-by-reference
47
The idea is that instead of passing the value to a function we pass __. In this way we have direct access to the cell containing the actual parameter and can modify its content.
a pointer to that value
48
Arrays :
are the simplest way of grouping data. An array is a sequence of homogeneous data that can be accessed using their position.
49
The size of the array should be known at _.
compile time
50
Arrays are actually _.
addresses to the first element of the sequence
51
A is :
the address of A[0]
52
*A is just another way of writing _
A[0]
53
p + 1 is evaluated to the arithmetic operation _
p + sizeof(T )
54
p − 1 is evaluated to the arithmetic operation _
p − sizeof(T )
55
A[n] becomes _
∗ (A + n)
56
For arrays declared as T A[N], A is _. So, we cannot modify __, e.g., doing A + +, this also means that _.
not a variable (just a name) A &A = A
57
But remember that parameter passing is still _ for the array itself
by-value
58
arrays issues:
We cannot return arrays in functions. We cannot have large arrays. The size of the array must be known at compile time.
59
The solution to all three problems of arrays is to _.
use dynamic allocation of memory
60
characteristics oh the heap:
The heap is much bigger than the stack. Values on the heap do not disappear unless we explicitly free the memory. Allocating portions of the heap at run time is not problematic since it does not interfere with the working of functions.
61
The _ offers functions to manage the heap
standard library (stdlib.h)
62
calloc
(n, size): allocates n many contiguous cells of memory each of size size and initializes all bits to 0
63
malloc
(n*size): allocates n many contiguous cells of memory of size size in total.
64
free(p):
takes a pointer to a piece of memory in the heap and deallocates the pointed space.
65
In C _ are used to implement strings. A string is _
arrays just an array of characters.
66
char *s=”this is a string.” → __ char s[ ]= “this is a string” == _
immutable, like a constant char A[ ]={‘t’,’h’,'i','s',...} !!!
67
Note that every string must end with a “hidden” special character:
′\0′ !!! pas oublier les ' ' !!!!
68
any constant string is _.
a constant array of characters whose elements cannot be modified
69
The standard library offers many functions that can help deal with strings. To use them include _.
string.h
70
How to concatenate the string in s1 and s2 and put the result in s1? The programmer has to ensure that _
strcat(char ∗ s1, const char ∗ s2) s1 has enough space to contain the concatenation
71
__: compares s1 and s2 and returns an integer. The return value is : <0 if s1 is __ than s2, 0 if _ a number > 0 if s1 is __ than s2
strcmp(const char ∗ s1, const char ∗ s2) lexicographically smaller the two strings are equal lexicographically bigger
72
__: the characters of s2 are copied in s1.
strcpy(char ∗ s1, const char ∗ s2)
73
__: returns the number of characters in s.
strlen(const char * s)
74
Important: If you need to pass a matrix as a parameter, the formal parameter must include the size of the number of _.
columns