1730 - Midterm Deck Flashcards

1
Q

What is a program

A

a program is a set of instructions for a computer

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

What is an algorithm

A

an algorithm is a step-by-step approach to solving a problem

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

what kind of codes/languages did early computers use

A

machine code (binary) and assembly languages

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

what are some examples of high-level languages that we know

A

Java and C

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

how are higher-level languages better for us

A

they allow programmers to write code independent of hardware

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

what are some examples of operating systems

A

Unix, Windows, MacOS, Linux

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

what do operating systems do

A

manage computer resources and provide an interface for the users

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

what does a compiler do

A

it analyzes a program developed in a particular computer language and translates it into a form that is suitable for execution on your particular computer system

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

what is a syntactic error

A

an syntax error (like unbalanced parenthesis or brackets)

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

what is a semantic error

A

an error that occurs when special data is inserted when not defined (so like when you have an undefined variable)

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

compilation process

A

reads code line-by-line and if any error is found, it tells the programmer and ends.

if no semantic or syntactic errors are found then compiler translates code from higher lang. to lower lang. for the computer to understand

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

what process does the term “building” refer to

A

the process of compiling and linking a program

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

what happens after the compilation process

A

the compiled file is then linked to an executable file

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

what happens when linking

A

the assembler takes each assembly language and converts it into a binary format known as object code

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

what is the default name of an executable file in Unix

A

a.out

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

what is the difference between unsigned and signed numbers

A

unsigned = non-negative values, while signed includes negative values

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

i have a file called file1.txt on my laptop that I want to upload to odin… what would I type in?

A

scp file1.txt odinUsername@odin.cs.uga.edu:~/[relative path to where you want to upload it on odin]

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

I have a program called Connect4.c on odin that I want to download on my laptop… what would I do

A
  1. cd to where you want to save in on your device
  2. scp odinUdername@odin.cs.uga.edu:~/[realtive path of where the file is on odin/Connect4.c .
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what are the 3 programming goals

A
  1. correctness
  2. readability
  3. optimization
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

difference between Java and C/C++ on compiling

A

Java needs a JVM, so when a program is compiled, the compiler produces a .class file that the JVM can understand.

C/C++ does not require a VM as the result of a “build” is an executable file that will run on the native operating system

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

what is the act of creating an executable file known as in C

A

linking

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

can you individually compile source files into object files in C like you have to in Java?

A

yes, you can.

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

what are the phases of C/C++ programs

A
  1. Edit
  2. Preprocess
  3. Compile
  4. Link
  5. Load
  6. Execute
24
Q

T/F: Java has a preprocessor

A

False, and it is one of the most noticeable differences between Java and C/C++

25
Q

What is the C equivalent for import java.lang.String;

A

include <string.h></string.h>

26
Q

what are some differences between Java and C/C++ in terms of memory

A

in C/C++, you must manually deallocate memory using the free (C)/delete (C++) method; whereas Java has an automatic garbage collector so the programmer does not have to worry as much about memory

27
Q

Are pointers more powerful in Java or C/C++?

28
Q

how many byes is a char

29
Q

how many bytes is an int

30
Q

how many bytes is a double

31
Q

how many bytes is a float

32
Q

how many bytes is a long

33
Q

how many bytes is a short

34
Q

is C/C++ case sensitive

35
Q

what is the java equivalent to a final variable

A

constant (ex. const char = ‘a’;)

36
Q

what does &foo return

A

the memory address of foo

37
Q

what is an array

A

an array is a sequence of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to the unique identifier

38
Q

T/F: an array can be dynamically-sized

A

false, arrays have a fixed size

39
Q

T/F: int a[3][5] is the same as int a[15]

A

true, any multidimensional array can be written as a simple array

40
Q

how to pass an array as a parameter

A

you declare the parameter to be the array, but omit the size in the bracket
int main(int argc, int argv[ ]) { }

(when you do this, you need a variable to tell you the length of the array, which is argc in this case)

41
Q

T/F: when calculating the length of an char array, the program adds 1 to the length because the computer is dumb

A

false; it adds 1 to the length because every char array as a ‘\0’ character at the end to null-terminate the array

42
Q

2 ways to initialize a character array:

A
  1. like you would normally do for any array:
    char myword[ ] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’};
  2. the string literal way:
    char myword[ ] = “Hello”;
43
Q

if we have char myword[] = “Hello”; can we do char myword[] = “Bye”

A

no, this won’t compile, to chance the contents of myword, the user would have to manually do so:
myword[0] = ‘B’;
myword[1] = ‘y’;
myword[2] = ‘e’;
myword[3] = ‘\0’;

44
Q

what is the reference operator

45
Q

what is the dereference operator

A

*(and is attached to the variable)

46
Q

how to initialize a pointer

A

type * name
example -> int * number

47
Q

what is a pointer

A

a variable that stores the address of another variable

48
Q

how are dereference variables translated

A

the value pointed to by
baz = *foo; baz is the value pointed to by foo.

49
Q

how are reference variables translated

A

& is the “address of”
foo = &myvar; foo is the address of myvar

50
Q

what is int * p1, p2

A

p1 is a pointer and p2 is simply an int
int * p1;
int p2;

51
Q

int myarray[20];
int * mypointer;

mypointer = myarray;

Why is this valid?

A

mypointer is assigned to the memory address at which myarray begins

52
Q

what is the main difference between pointers and arrays

A

pointers can be assigned to new addresses, while arrays cannot

53
Q

what is a[5] equal to in pointer form

54
Q

which has more precedence in this statement: *p++ = *q++

A

++ has greater precedence than *

55
Q

what is *p++ = *q++ roughly equivalent to

A

*p = *q
++p;
++q;

56
Q

what is the main reason for byte alignment

A

to improve memory access speed