1730 - Midterm Deck Flashcards

(56 cards)

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
What is the C equivalent for import java.lang.String;
#include
26
what are some differences between Java and C/C++ in terms of memory
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
Are pointers more powerful in Java or C/C++?
C/C++
28
how many byes is a char
1 byte
29
how many bytes is an int
4 bytes
30
how many bytes is a double
8 bytes
31
how many bytes is a float
4 bytes
32
how many bytes is a long
8 bytes
33
how many bytes is a short
2 bytes
34
is C/C++ case sensitive
yes!
35
what is the java equivalent to a final variable
constant (ex. const char = 'a';)
36
what does &foo return
the memory address of foo
37
what is an array
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
T/F: an array can be dynamically-sized
false, arrays have a fixed size
39
T/F: int a[3][5] is the same as int a[15]
true, any multidimensional array can be written as a simple array
40
how to pass an array as a parameter
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
T/F: when calculating the length of an char array, the program adds 1 to the length because the computer is dumb
false; it adds 1 to the length because every char array as a '\0' character at the end to null-terminate the array
42
2 ways to initialize a character array:
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
if we have char myword[] = "Hello"; can we do char myword[] = "Bye"
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
what is the reference operator
&
45
what is the dereference operator
*(and is attached to the variable)
46
how to initialize a pointer
type * name example -> int * number
47
what is a pointer
a variable that stores the address of another variable
48
how are dereference variables translated
the value pointed to by baz = *foo; baz is the value pointed to by foo.
49
how are reference variables translated
& is the "address of" foo = &myvar; foo is the address of myvar
50
what is int * p1, p2
p1 is a pointer and p2 is simply an int int * p1; int p2;
51
int myarray[20]; int * mypointer; mypointer = myarray; Why is this valid?
mypointer is assigned to the memory address at which myarray begins
52
what is the main difference between pointers and arrays
pointers can be assigned to new addresses, while arrays cannot
53
what is a[5] equal to in pointer form
*(a+5)
54
which has more precedence in this statement: *p++ = *q++
++ has greater precedence than *
55
what is *p++ = *q++ roughly equivalent to
*p = *q ++p; ++q;
56
what is the main reason for byte alignment
to improve memory access speed