CISC210 FINAL

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

1/100

encourage image

There's no tags or description

Looks like no tags are added yet.

101 Terms

1
New cards

SSH stands for "Secure Shell"

True

2
New cards

In the context of this course, "CLI" stands for:

a. Command Line Installation

b. Common Legal Infrastructure

c. Computer Logic Interface

d. Command Line Interface

e. Children's Learning Institute

Command Line Interface

3
New cards

Both option arguments and regular arguments to bash commands are sometimes optional.

True

4
New cards

What command could you use to list the files in the current working directory?

ls

5
New cards

When a directory is removed by the command "rm -rf directorynamehere", what do the options r and f stand for? (You might consider checking "man rm" for the answer).

a. recursively, fastly

b. remove, fastly

c. recursively, forcefully

d. remove, forcefully

recursively, forcefully

6
New cards

Enter commands to make a directory called "bus" in your current directory and copy an already-existing file "driver" into "bus".

mkdir bus

cp driver bus

7
New cards

Enter commands to make a directory called "bus" in the parent of your current directory and create a file called "driver" under "bus".

"driver" may have any content (including none), but you may not use any text editor commands (like "vim").

mkdir ../bus

touch ../bus/driver

8
New cards

Enter commands to make a directory called "lantern" in your current directory and a directory called "oil" under that. Change the current working directory to "oil".

mkdir lantern

cd lantern

mkdir oil

cd oil

9
New cards

What is the word cat short for?

Concatenate

10
New cards

What file is created by running the command:

gcc hello.c

a.out

11
New cards

int

%d

12
New cards

char

%c

13
New cards

character array (string)

%s

14
New cards

Which command should you use to create a new local copy of an existing repository?

a. git clone

b. git push

c. git pull

d. git get

e. git init

git clone

15
New cards

When using git, after you've worked on a project for a while and have some working code you should:

a. commit, then push

b. pull, then clone

c. push, then clone

d. push, then commit

e. clone, then commit

commit, then push

16
New cards

Consider the following sequence of commands and messages:

$ git clone git@gitlab:YOU/example # YOU means your user name Cloning into 'example'... remote: Counting objects: 19, done. remote: Compressing objects: 100% (12/12), done. remote: Total 19 (delta 1), reused 0 (delta 0) Receiving objects: 100% (19/19), done. Resolving deltas: 100% (1/1), done. $ touch sky $ git add sky fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Enter two commands that would make it so the 'git add' wouldn't fail.

Error is because you need to change into the cloned repo first!

cd example

touch sky

17
New cards

The parent id of a process is:

a. The name of the current working directory of the process.

b. The number that uniquely identifies the process in question.

c. The number that uniquely identifies the process that started the process in question.

d. The number that uniquely identifies the user account that started the process in question.

e. The number assigned by the parent to the process in question.

The number that uniquely identifies the process that started the process in question.

18
New cards

Fix this program so it compiles and produces the expected output.

#include

int main(void) {

float x;

scanf("%f",&x);

printf("%.1f %.1f",x,sqrt(x));

return 0;

}

Add #include

19
New cards

Which of the following is used to make a single line comment in C?Hint: the answer can be found in "Dive Into Systems" section 1.1

a. #

b. %

c. /*

d. */

e. //

//

20
New cards

Write C code to define a double variable called height and an integer variable called age.

double height;

int age;

21
New cards

Which of the below are true? Select all that apply.

a. There are many Linux distributions.

b. UNIX is a derivative of Linux.

c. There have been many variants of UNIX.

d. Linux is a derivative of UNIX.

e. Linux Torvalds is solely responsible for the development of Linux.

There are many Linux distributions.

There have been many variants of UNIX.

Linux is a derivative of UNIX.

22
New cards

Enter a command that will cause "Bonjour, monde!" to appear in the terminal.

echo "Bonjour, monde!"

23
New cards

Which of the following are correct with respect to UNIX file names (select all that apply)

a. File names must start with a letter

b. There can be files with the same name in two different directories.

c. Spaces are allowed in file names, but make them hard to work with.

d. File names are case sensitive (i.e., "File" and "file" are different names)

e. "/root" is the top directory in the Unix file system.

There can be files with the same name in two different directories.

Spaces are allowed in file names, but make them hard to work with.

File names are case sensitive (i.e., "File" and "file" are different names)

24
New cards

Which of the following options of the grep command is used for "Invert the sense of matching, to select non-matching lines."?

-v

25
New cards

double

%f

26
New cards

percent character

%%

27
New cards

Write code (not a function) that reads two integers typed by the user and prints the sum.

int x;

int y;

scanf("%d%d",&x, &y);

printf("%d", x + y);

28
New cards

On a typical day of working with Git, you'll start by using ______________ , and then each time you have finished fixing a bug or adding a feature, you'll run ______________ , ______________ , and Blank ______________ (in that order).

git push - git add - git commit - git pull

git pull; git add; git commit; git push

29
New cards

Two functions abra and cadabra have been defined with the following prototypes:

int abra(float);float cadabra(int);

Write code that will call abra() with an argument of 7.3, cadabra() with the return value from the call to abra(), and print the result from cadabra() to two decimal places

int ans = abra(7.3);

printf("%.2f", cadabra(ans));

30
New cards

The "Body Mass Index" (BMI) of a person is defined to be their mass in kilograms divided by the square of their height in meters.

Assuming that float variables inches and pounds have already been defined and given values. Write C code (not a function!) that prints the BMI of an individual with that height and weight as follows (one decimal place for pounds and BMI, no decimal places for inches):

A person who weighs 197.2 pounds and is 72 inches tall has a BMI of 26.7.

Note: use the following conversion ratios

1kg = 2.20462 pounds

1m = 39.37 inches

Note: this can be done in one line, but doesn't need to be.

float kg = pounds / 2.20462;

float meters = inches / 39.37;

float bmi = kg / (meters * meters);

printf("A person who weighs %.1f pounds and is %.0f inches tall has a BMI of %.1f.\n", pounds, inches, bmi);

31
New cards

Write a function show_ascii that consumes a char and prints the character and its ASCII value on the same line separated by a space. The function should return nothing.

void show_ascii(char word){

printf("%c %d", word, word);

}

32
New cards

Assume that mass has already been declared as a floating-point value. Write a line which will read a value for mass from stdin (usually the keyboard).

scanf("%f", &mass);

33
New cards

Define a function average that consumes three float arguments and returns the (float) average of them.

float average(float num1, float num2, float num3){

float sum = num1 + num2 + num3;

float avg = sum/3;

return avg;

}

34
New cards

A variable has been declared and initialized by:

int x = 9;

How would you assign the address of the memory location at which 9 is stored to a previously-declared variable p2x?

p2x = &x;

35
New cards

Consider the following program:

#include

/ function declaration /

void function(int x, int y, int z);

int main () {

int a = 100 , b , c ;

function (a, &b, &c); }

void function(int x, int y, int z) {

x = x + 2;

*y = x - 1;

*z = x + 1;

}

What are the final values of a, b, and c respectively?

(100, 101, 103 )

36
New cards

Which of the following is false?

a. Compiler error messages contain information like the line number and error type.

b. You can use standard error output by adding lines such as fprintf(stderr, "in function updatelife, in second loop, variable i is %d\n", i);

c. The most effective way to debug code is to read it carefully.

d. Standard error output can be redirected into a file separately from standard out.

e. Adding print statements to display the values of variables is a useful debugging tool.

f. You can access the contents of a file that is being added to while the program is running by using the cat or tail commands.

The most effective way to debug code is to read it carefully.

37
New cards

Match each GDB action with the command that performs it

.

Execute the current line, and stop on the next line to be executed, even if that next line is inside a function call.

step (s)

38
New cards

Match each GDB action with the command that performs it.

Execute the current line, including completing any function calls, and stop on the next line.

next (n)

39
New cards

Match each GDB action with the command that performs it.

Execute the program currently being debugged.

run (r)

40
New cards

Match each GDB action with the command that performs it.

Indicate a variable or memory location that will cause the program to pause when the value is changed.

watch (w)

41
New cards

Match each GDB action with the command that performs it.

Designate a place for the program to pause execution.

break (b)

42
New cards

QUIZ 5 QUESTION 9

Empty

43
New cards

The command ls -R shows all files and directories under the current working directory, listing the contents of all directories, and the contents of those recursively. Assume the output of ls -R looks like:

.:

fido parent ./fido:

./parent:

child

./parent/child:

grandchild

Enter unix commands that will move fido under child without creating any new files or directories.

mv fido parent/child/

44
New cards

Which of the following compiles a source-code file called hello.c into an executable called

greeting?

a. cc greeting hello.c

b. cc -o hello.c greeting

c. cc -g greeting hello.c

d. cc hello.c greeting

e. cc -o greeting hello.c

cc -o greeting hello.c

45
New cards

Enter one line of code that could be added to the beginning of this short program that will permit it to compile:

int main(void) {

return compute_square(7.3);

}

float compute_square(float side) {

return side*side;

}

//prototype!

float compute_square(float side);

46
New cards

The following is a quantity represented in binary. What is its representation in decimal?

111111

63

47
New cards

How can you represent the number seven using five bits? (A "bit" is a "binary digit", i.e., a single 0 or 1 in a binary representation).

Hint: think about representing twelve in decimal using three digits.

00111

48
New cards

QUIZ 6 QUESTION 6

Empty

49
New cards

QUIZ 6 QUESTION 7

Empty

50
New cards

How many times will this loop execute? (use -1 to indicate that it is an infinite loop)

for(int i = -5; i+1; i++) {

i++;

}

2 (i+1 means keep looping until it reaches 0)

51
New cards

A Makefile is most like:

a. A compiler.

b. A textbook

c. A police lineup.

d. A recipe book.

e. A clothes pattern.

A recipe book

52
New cards

QUIZ 6 QUESTION 10

Empty

53
New cards

Which of the following will be considered "true" in an if statement?

a. 0.0

b. 1

c. 0

d. "no"

e.-1

f. 2.2

1; "no"; -1; 2.2

54
New cards

What will be the last line printed by this program? (Enter '-1' if the program will never stop printing).

#include

int main(void) {

for(int i=0; i<17; i++) {

if (i%3 && i%2) {

printf("%d\n",i);

}

}

return 0;

}

13

55
New cards

Fix the below code to read a word from stdin and print the ASCII value of the first letter entered.

char buff[20];

scanf("%s", _______);

printf("%d", _________);

buf (no & needed for array); (int)buf[0]

56
New cards

Which of the following will not properly initialize a string?

a. char str[8] = "good!";

b.char str[] = "good!";

c. char str[5] = {'g', 'o', 'o', 'd', '!'};

d. char str[8] = {'g', 'o', 'o', 'd', '!', '\0'};

e. All of the above will work.

f. None of the above will work.

char str[5] = {'g', 'o', 'o', 'd', '!'};

57
New cards

An integer array ints has already been declared to be an array of 23 elements (so, in memory, it is 23 integers in a row).

Declare a variable p2last that points to the last element in the array ints.

int *p2last = &ints[22];

58
New cards

The following is a quantity represented in base-8 (octal). What is its representation in base-10 (decimal)?

(The right-most digit is still the one's place, the next is the 8s place, ...)

772

506

59
New cards

PRACTICE QUIZ 7 PROBLEMS 7-10

Empty

60
New cards

Consider this positive integer value represented in binary:

...01100100

Where the "..." means that there is an unknown set of bits to the left. Which of the following are true (select all that apply)?

a. The number is divisible by four.

b. The number is at most one-hundred twenty-seven.

c. The number is odd.

d. The number is at least sixty-four

e. The number is even.

f. The number is at least one-hundred twenty-seven.

The number is at least sixty-four

The number is even.

61
New cards

Write a Makefile with a recipe which can be used to compile myprog.c into myprog. Be sure to indicate that "myprog" depends on myprog.c!

myprog: myprog.c

gcc -o myprog myprog.c

62
New cards

What will be printed if the following function is called from main()? Assume stdin.h has been included.

void f(void) {int x;printf("%d\n",x);}

a. 0 will be printed.

b. A run-time error will occur.

c. An unknown value will be printed.

d. A compiler error will occur.

C does not intialize local variables. Contents of x will be whatever random value was already in memory. An unknown value will be printed.

63
New cards

Which of the following initialize valid C strings (select all that apply).

a. char c[] = 'Hello';

b. char c[] = {'h','e','l','l','o'};

c. char c[] = {121,101,115,0};

d. char c[] = "Hello";

e. char c[] = {'h','e','l','l','o','\0'};

char c[] = {121,101,115,0}; char c[] = "Hello"; char c[] = {'h','e','l','l','o','\0'};

64
New cards

What will happen when this program is compiled and run.

#include int main(void) {int a=1, arr[2], b=2;for(int i=0; i<3; i++) {arr[i] = i+3;}printf("%d %d",a,b);for(int i=0; i<3; i++) {printf(" %d",arr[i]);}printf("\n");return 0;}

a. A compiler error.

b. A compiler warning.

c. 1 2 3 4 5is printed

d. A run-time error.

e. Something other than "1 2 3 4 5" will be printed.

f. None of the above is certain: it will depend on the compiler, the compiler flags, and other considerations.

A run-time error.

65
New cards

Match the error message with the likely cause.

In function `main': undefined reference to `getFrameBuffer'

A missing link flag: "-lsense"

66
New cards

Match the error message with the likely cause.

error: unknown type name 'pi_framebuffer_t'

A missing line in the .c file: #include "sense.h"

67
New cards

Match the error message with the likely cause.

/usr/bin/ld: cannot find -lsense

A missing link flag "-L ~ /lib"

68
New cards

Match the error message with the likely cause.

fatal error: sense.h: No such file or directory #include "sense.h"

A missing compile flag: "-I ~/include"

69
New cards

Fix this program so it prints correctly.

Note: don't look for some deep, complex problem. It's basic.

#include

int main(void) {

char tod[32]="";

scanf("%s",tod);

char ho[2],mi[2],se[2];

ho[0]=tod[0]; ho[1]=tod[1]; ho[2]='\0';

mi[0]=tod[3]; mi[1]=tod[4]; mi[2]='\0';

se[0]=tod[6]; se[1]=tod[7]; se[2]='\0';

printf( "T: %sH %sM %sS\n" ,ho,mi,se);

return 0;

}

change ho[2], mi[2], and se[2] to ho[3], mi[3], se[3] to allocate for space.

70
New cards

Supposed variables have been declared in main() as int a=7, b=4;

Which of the following functions could be used to exchange the values of a and b?

Question 4Select one:


void funa(int x , int y)
{
    int t;
    t=x;x=y;y=t;
}




b.

void funa(int *x , int *y)
{
    int *p;
    *p=*x;*x=*y;*y=*p;
}

c.


int funa(int *x , int *y)
{
    *x=*y;*y=*x;
}




d.

void funa(int *x , int *y)
{
    int t = *x;
    *x = *y;
    *y = t;
}

e.

Any of the above will work. 

f.

None of the above will work. 

void funa(int x , int y) { int t = x; x = y; y = t;

}

71
New cards

What will be the value of var at the end of the following code?

int var = 0;

int arr[] = {5,7,8};

var = *(arr+2);

a. This will be a compilation error.

b. 8

c. This will be a run-time error.

d. 2

e. 5

f. Two bytes after the memory address of arr

g. Eight bytes after the memory address of arr

h. The memory address of arr

8

72
New cards

lowest addresses to the highest addresses.

a. stack; heap; datal code; operating system; unallocated

b. operating system; code; data; heap; unallocated; stack

c. stack; unallocated; heap; data; code; operating system

operating system; code; data; heap; unallocated; stack

73
New cards

Consider this line found in a long-running program:int *ints = malloc(40);After the allocated memory is no longer required by the program, (choose one of the below)

a. free() should be called with the value of ints

b. free() should be called with no arguments

c. The garbage collector will clean up the unneeded memory.

d. Any of the other actions can be taken.

e. None of the other actions should be taken.

free() should be called with the value of ints

74
New cards

Which of the following might correctly be used in a function prototyped as:

char toUpper(char );

that duplicates a string and converts all lower-case characters to upper case (returning the new string without changing the old)?

a. char newstr = malloc(strlen(oldstr)sizeof(char));

b. char newstr = malloc(sizeof(oldstr)sizeof(char));

c. char *newstr = oldstr;

d. char newstr = malloc((strlen(oldstr)+1)sizeof(char));

e. char newstr = malloc((sizeof(oldstr) + 1)sizeof(char));

char newstr = malloc((strlen(oldstr)+1)sizeof(char));

75
New cards

Consider this program:

int func(int arg) {int ret = arg + 1;}int main(void) {int eye = 0;int jay = func(eye);}

Which of the following statements is definitely correct?

a. func() could just return a pointer to ret

b. ret will be stored on the stack at a higher address than eye

c. ret will be stored on the stack at a lower address than eye

d. arg will be stored in the program code

e. jay will be stored on the stack at a lower address than eye

ret will be stored on the stack at a lower address than eye

76
New cards

Suppose you must write a function with the following prototype:

char copy_string(char str);

The function should allocate memory on the heap for the duplicated string. Which of the following would be the best line (not necessarily the best possible line) to allocate the required memory?

a. char *dup = malloc(sizeof(str));

b. char dup = malloc(sizeof(char)strlen(str));

c. char *dup = malloc(str);

d. char *dup = free(str);

e. char dup = malloc(sizeof(char)(strlen(str)+1));

char dup = malloc(sizeof(char)(strlen(str)+1));

77
New cards

What is the data type of var as declared by:

int *var[3];

a. A pointer-to-integer

b. An array of three pointers to integers.

c. An array of three strings.

d. An array of three integers.

e. A pointer to an array of three integers.

An array of three pointers to integers.

78
New cards

Consider the following program, what can be the possible output of it? Assume sizeof(int) == 4 and sizeof(int*)==8.

#include

int main () {

int var[] = {10, 100, 1000};int i, *ptr;

/ array address in pointer /

ptr = var;

for ( i = 0; i < 3; i++) {

printf("%p %d \n", ptr, *ptr );ptr++;

}

return 0;

}

a. 0xc1c251c4 100xc1c251c8 1000xc1c251cc 1000

b. 10 0xc1c251c4 100 0xc1c251c8 1000 0xc1c251cc

c. compile error

d. 0xc1c251c0 100xc1c251c8 1000xc1c251cc 1000

e. 0xc1c251c4 100xc1c251c0 1000xc1c251cc 1000

0xc1c251c4 100xc1c251c8 1000xc1c251cc 1000

79
New cards

Assume an array has been declared as

float arr[20][7];

What value of m can be used so the following is true?

(float*)arr + m == &(arr[5][1])

(i.e., arr[5][1] is m floats ahead of arr in memory)

36

80
New cards

QUIZ B QUESTION 8

Empty

81
New cards

Assume a structure and variable head declared using:

typedef struct _node {

int data;struct _node *next;

} nodeT;

nodeT *head;

Which of the following could be used to declare a variable nn that could be used in the assignment:nn = head->next->next;

a. nodeT **nn;

b. int nn;

c. nodeT nn;

d. nodeT ***nn;

e. nodeT *nn;

nodeT *nn;

82
New cards

Your current working directory is "thisdir". Enter commands to change the name from "thisdir" to "thatdir" and end with your current working directory being "thatdir". Don't rename any other files or directories.

cd ..

mv thisdir thatdir

cd thatdir

83
New cards

Below is a value represented in binary, where ! indicates "one" and * indicates "zero". What is the value represented in decimal (base-ten)?

13

84
New cards

char c=malloc(sizeof(char));int i = malloc(sizeof(int));char s=malloc(20sizeof(char));double *d = malloc(sizeof(double)); int sc=sizeof(c), si=sizeof(i), ss=sizeof(s), sd=sizeof(d);

In light of the above code, which of the following is true? Remember what is actually stored in each variable!

a. Each integer will be the same size.

b. sc will be the smallest

c. ss will be the largest

d. sd will be the largest

e. there's no way to tell which of the integers is smallest

Each integer will be the same size.

85
New cards

Assume a structure is defined as follows:

struct node {

int data;

struct node *next;

}

and that variables have been defined as:

struct node head, nn;

and given appropriate values. Which of the following will prepend nn to the beginning of the linked list referenced by head (i.e., attach nn to the beginning of the list)?

a.nn->next = head->next;head = nn;

b. nn->next = head;head = nn;

c. nn->next = head->next;head->next = nn;

d. nn.next = head;head = nn;e.nn = head->next;head = nn->next;

nn->next = head;

head = nn;

86
New cards

Consider this code:

int a[5]; int *p = malloc(20);

Which of the following would produce a compile error (not a warning, an actual error, keeping in mind that "addresses" are mathematically integers)? Select all that apply.

a.*a = 1027;

b.p = 1027;

c.a = 1027;

d.a = p;

e.p = a;

f.*p = 1027;

a = 1027;

a = p;

87
New cards

In Unix systems, all devices are

a. handled differently

b. treated as files

c. treated as directories

d. usable only by the root user

e. found in the /devices directory

treated as files

88
New cards

Enter a Bash "glob" expression which will match exactly the files in the current directory that start with a lower-case 'a' and end with '.c'

a*.c

89
New cards

Which of the following is not a feature of i2c?

a. Star topology

b. Clock wire

c. Bus connectivity

d. Serial communication

e. Data wire

Star topology

90
New cards

On cisc210.cis.udel.edu, type

man ls

This will show you the manual page for the ls command. You can see that ls has a considerable number of options available!

Which option can be used to reverse the default ordering of the listing?

a. -v

b -V

c. -R

d. -T

e. -r

f. -t

-r

91
New cards

On cisc210.cis.udel.edu, type

man ls

This will show you themanual page for thelscommand. You can see thatlshas a considerable number of options available!

Which option can be used to recursively search subdirectories?

a. -T

b. -R

c. -r

d. -v

e. -V

f. -t

-R

92
New cards

On cisc210.cis.udel.edu, type

man cat

This will show you the manual page for the cat command.

What is the word cat short for?

a. computer aided teaching

b. computer aided translation

c. concatenate

d. content analysis tool

e. category

f. catalog

concatenate

93
New cards

On cisc210.cis.udel.edu, type

man cat

This will show you the manual page (or man page) for the cat command.

What other command does the man page suggest you might be interested in?

a. more

b. none

c. tac

d. ls

e. less

f. dog

tac

94
New cards

Based on what you read there, enter a command that will output just the last line of the file myfile.csv.

tail -n 1 myfile.csv

95
New cards

The touch command has two main uses

1. it can change the time stamp on a file, recording a different creation, modification, or access time

2. It can create an empty file with a given name (there are other ways to do this as well).

(see man touch for more details)

Enter a command to create an empty file named nonsense.

touch nonsense

96
New cards

What file(s) are created by the following command (assuming no errors):

cc test.c

You can check with the following trivial C program:

int main(void) { return 0; }

Please note: as a multiple-choice question, there will be a penalty applied for each incorrect submission.

a. test.c

b. No files are created

c. test.o

d. test.s

e. a.out

a.out

97
New cards

What file(s) are created by the following command (assuming no errors):

cc -c test.c

As a multiple-choice question, there will be a penalty applied for each incorrect response submitted.

a. No files are created

b. test.o

c. test.s

d. a.out

e. test.c

test.o

98
New cards

What file(s) are created by the following command (assuming no errors):

cc -S test.c

a. test.c

b. No files are created

c. a.out

d. test.o

e. test.s

test.s

99
New cards

What file(s) are created by the following command (assuming no errors):

cc -E test.c

As a multiple-choice question, there will be a penalty applied for each incorrect response submitted.

a. test.o

b. test.c

c. a.out

d. No files are created

e. test.s

No files are created

100
New cards

DO ALL PRACTICE CODING PROBLEMS B4 EXAM!!!!

Empty