Progweek1 Flashcards

1
Q

Unix was born in _

A

1973

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

Unix provides a _ between the _ and the _.

A

simple-to-use and powerful interface

user (the programmer)

hardware (the computer)

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

Unix was based on simple ideas:
1
2
3
4

A
  1. simple interface
  2. simple instructions that can be combined
  3. hierarchical file system
  4. independent from specific computer architectures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Since its development, Unix served as a _

A

base to develop operating systems

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

structure of systems developed by Unix:
⥐⥐⥐
1 ⇋ 2 ⇋ 3 ⇋ 4

A

1: user
2: shell
3: kernel
4: Hardware
2&&4: OS

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

The Unix shell is _.
It allows _.

A

an interface between the user and the operating system.

to run system commands.

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

why a shell?

A
  • powerful: Allows to solve
    many simple problems in a few
    lines.
  • Fast && flexible: offers
    a scripting language which
    often results in faster solutions
    to problems.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

syntax of commands

A

<options><parameters>
</parameters></options>

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

what is the command to list ll the file and directories in my desktop

A

l s −a

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

command that shows you the manual of the
specific command

+give eg

A

man

eg: man ls)

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

To work with objects in the file system we use their paths. There are two
ways of expressing the path of a file:

A
  1. Absolute: Starting from the root, e.g.: /Users/Lorenzo/Desktop
  2. Relative: Starting from the current
    position in the file system,
    e.g.: ./Lorenzo/Desktop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

“..”
meaning on the shell?

A

“the parent directory”

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

“.” meaning on the shell?

A

“this directory”

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

def of Files:

A

A sequence of bytes.

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

def of Path: (+eg)

A

The position in the file
system,e.g., /Users/Lorenzo/Desktop

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

def of Permission:

A

What can a user do with
the file read/write/execute for the owner,
owner group, everyone

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

hox to see permission on the shell?

A

use option ls -l

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

def of Directories:

A

A file that indexes other
files.

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

main ingredients of the file system:

A
  • files
    • path
    • permission
    • owner
    • dimension
    • last modified
  • directories
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

list the files in dir

A

ls dir

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

count words in file

A

wc file

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

count characters in file

A

mc file

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

count lines in file

A

lc file

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

look for all the lines in the file that match the expression

A

grep expression file

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

redirects the output of the command to a file

A

command > file

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

edirects the output of the command to a file with append

A

command&raquo_space; file

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

use the ouput of command1 as input of command2

A

command1 | command2

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

command1 is executed successfully
executes command2

A

command1 && command2

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

Vim is a _ yet quite _ file _.

A

minimal

powerful

file editor

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

In a few words, C is:

A
  • Imperative
  • Typed
  • Low level
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

pros of C

A
  • Efficient (you have full control
    on use of resources)
  • Fast (you can usually
    implement very fast programs,
    e.g., using bit manipulation)
  • Good if you want to implement
    low level applications
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

cons of C

A

Limited degree of abstraction

Limited run time support

Limited portability

Low level of security

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

what is “int main()” ?

A

declares a function which is called “main” and returns an
integer.

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

def of Interpreter:

A

Program that executes code written in the high-level language. This is the typical approach of functional and scripting languages, standard in Python.

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

def of compiler

A

The compiler translates the code to the target language
producing an executable file. This is the standard approach in most
imperative languages, standard in C.

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

C programs are complied:

hello.c → 1 → 2 → 3 ⇒ 4

A
  1. preprocessor
  2. compiler
  3. linker
  4. executable code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Preprocessing:

A

takes care of lines that start with “#”

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

Compiling:

A

takes the code obtained from the preprocessor and
produces code that can be executed by the hardware

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

Linking:

A

links the object file to external libraries

40
Q

This is how you should compile your programs:

A

gcc -Wall -pedantic -g -o helloworld helloworld.c

41
Q

When you want to learn a new language there are a few things you need
to check:

A

The paradigm: Imperative, functional, logic, etc.

The type system: Typed/Untyped, explicit/inferred, type operators,
etc.

the basic syntax

scope of names

parameter passing

memory management

42
Q

def of commands

give eg

A

roughly, a command is a piece of code that changes the
memory (i.e., in general commands do not return values). The main
example is assignment which assigns a value to a variable (i.e.,
essentially a piece of memory with a name).

43
Q

def of expressions

give eg

A

expressions are roughly pieces of code that can be
evaluated to obtain a value, e.g., 3 + 2, x + y , sin(3) are all
expressions.

44
Q

Programming languages can be roughly divided as follows:

A

imperative

functional

logic

object-oriented

45
Q

def of imperative:

give eg

A

Programs have a state (snapshot of memory, instruction
counter, etc.) and consists of a sequence of commands (Examples: C,
Pascal, etc).

46
Q

def of functional

give eg

A

A program consists of function declarations and compositions.
Problems are solved in a way that is closer to how we think in mathematics.
(Examples: Racket, ML, Haskell, etc)

47
Q

def of logic

give eg

A

A program consists of a collection of logical clauses which describe
properties of the problem and of the solution. The execution of the program
finds a solution matching the requirements. (Examples: Prolog, ASP, etc) .

48
Q

def of object oriented

give eg

A

This programming approach uses “objects” which contain data and operations. It’s often combined with other programming styles. Examples of OOP languages are C++, Python, Java, and Ocaml.

49
Q

very program has the
following structure:

1
2
3

A
  1. preprocessor directives
  2. global declaration
  3. function implementation
50
Q

To work with data in our programme we use two basic constructs:

A
  1. variables
  2. constants
51
Q

def of variables

A

a piece of memory with a name (called identifier) whose
size depend on the type of the content and whose content can change
during the execution of the program.

52
Q

def of constants:

A

a piece of memory with a name whose size depend on the
type of the content and whose content cannot be changed during the execution of the program.

53
Q

def declaration:

A

we specify the name and type of the variable (memory is
allocated).

54
Q

def initialization:

A

we assign a value to a variable for the first time.

55
Q

A data type is:

A
  • a collection of objects ({. . . , 1, 0, 1, 2, . . .} for int)
  • a collection of operations (+, ⇤, , / etc. for int.)
56
Q

Primitive types:

A

these are the types that are available to the
programmer as building blocks of their program.

57
Q

Type constructors:

A

these are ways of defining new types.

58
Q

C is a _ programming language. This mean that variables, constant,
and expressions will contain/express only data of _.

A

typed

a specific type

59
Q

Types in
C must be mentioned _

A

explicitly

60
Q

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

A

includes the standard input-output library functions in a C program, such as printf and scanf.

61
Q

& in scanf(%d, &i):

A

is used to tell scanf the location (address) in memory where it should store the integer that it reads from the user input.

62
Q

Variables of type char are of _ byte(s) (_ bits) and can therefore
represent _ = _ characters.

A

one

8

2^8

256

63
Q

To check the size that a variable of a certain type occupies you can
use the function __ which returns the dimension in bytes
of the given type.

A

sizeof(type)

64
Q

The types float and double are used to represent __.

A

real numbers

65
Q

All floating types are _numbers

can you use the unsigned modifier?

A

signed

no

66
Q

Float are usually _ bytes long and double _ bytes long.

A

4

8

67
Q

The operator % is the modulo operator,.e.g,. 3%2 is 1. This operator
cannot be used with __.

A

double and float

68
Q

property of types:

  • → - → - →- → -→ _
A

char → int → long → float→double → long double

69
Q

how to do 2^5

A

pow(2,5)

70
Q

how to do |-5|

A

fabs(-5)

71
Q

False is represented by _

A

0

72
Q

True is represented by any value _

A

bigger than 0

73
Q

The most immediate application of boolean expressions are __

A

conditional statement

74
Q

Statements in a program are executed one after each other; this is know as _

A

sequential flow control.

75
Q

In C, a loop consists of two parts: the _ and the _

A

body

control statement

76
Q

A control statement :

A

indicates the condition(s) driving the loop by
executing the body until the condition or conditions become False.

77
Q

In C, the looping statements are classified into two types:

A

Entry controlled loop

Exit controlled loop

78
Q

Entry controlled loop:

A

the condition is checked before execution of the body.

79
Q

Exit controlled loop:

A

the condition is checked after execution of the body.

80
Q

while-loops, entry- or exit controlled?

A

entry

81
Q

for loops, entry- or exit controlled?

A

entry

82
Q

do-while loops, entry- or exit controlled?

A

exit

83
Q

if, if-else, and switch are _

A

conditional statements

84
Q

As you already have experience, if we are not careful we can end up in a case in which the expression will never become zero. This will lead to an _ , and we will be stuck forever!

A

infinite loop

85
Q

The condition in for loops is _ ; if it is nonzero (True),
control passes back to the beginning of the loop, and it stops
when False is returned.

A

a logical expression

86
Q

f o r ( 1; 2; 3) {
4 ;
}

A
  1. initialization
  2. condition
    3.update
  3. statements
87
Q

what does the do-while loop tests?

A

It tests the termination condition after each pass through the loop
body. The body is executed at least once!

88
Q

the break statement is a special command that _ _. It stops
__ a loop

A

interrupts the flow of control

prematurely

89
Q

the switch statement:

A

It is a way to generalize the conditional (if-else) statements. It compares constants.

90
Q

def of function:

A

is a block of code -or collection of statements- that runs when
is invoked. We can pass data (parameters) into a function.

91
Q

In C, the main() function is __. It is user-defined and mandatory!

A

”the entry point of a program where the execution starts”

92
Q

the main function is called by the _, not the _

A

OS

user

93
Q

i n c l u d e <s t d i o . h>
i n t a = 3 3 ;
i n t main ( ) {
i n t b = 7 7 ;
p r i n t f ( ” a = %d\n” , a ) ;
p r i n t f ( ”b = %d\n” , b ) ;
r e t u r n 0 ;
}

what is the global and the local variable?

A

local: b

global: a

94
Q

Local variables :

A

are declared in the body of a function

95
Q

Global variables :

A

are declared outside of any function, and are available
for any routine in the program

96
Q

unction prototype:

A

t y p e f u n c t i o N a m e ( p a r a m e t e r s ) ;