CECS 325 Midterm Review

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

1/39

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:25 AM on 10/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

40 Terms

1
New cards

What key is used to enter insert mode in Vim?

i

r

t

m

i

2
New cards

How can you save changes to a file and exit vim?

:write&exit

:save&quit

:exit

:wq

:wq

3
New cards

Which command is used to delete the character under the cursor?

d

z

r

x

x

4
New cards

What does the u key do in normal mode?

Moves the cursor to the end of the line

Copies the current line

Deletes the current line

Undoes the last change

Undoes the last change

5
New cards

How do you search forward for a specific word in Vim?

?word

&word

/word

#word

/word

6
New cards

Which command is used to copy the current line in normal mode?

cc

yy

dd

pp

yy

7
New cards

How can you move the cursor to the beginning of the current line?

$

H

0

G

0

8
New cards

What does the command :q! do?

Quits Vim with confirmation

The correct is not listed

Exits without saving changes

Saves changes and exits

Exit without saving changes

9
New cards

Which mode allows you to navigate and manipulate highlighted text?

Command mode

Visual mode

Insert mode

Replace mode

Visual mode

10
New cards

What does the :help command do?

Creates a new Vim session

Displays a help message

Opens a new empty bugger

Opens a file or editing

Displays a help message

11
New cards

What statement is true about the C++ language?

It is interpreted

It is compiled

None of these answers are correct

It was invented in 1968

It is compiled

12
New cards

How do you create an array of 20 integers called nums in C++?

nums[20]

int nums = new int[20];

integer nums[20];

int nums[20];

int nums[20];

13
New cards

In the C++ language when building a class, the function prototypes must be in a header file (.h) and the implementation must be separate in the .cpp file

True

False

False

14
New cards

When building a class in C++, it is good practice to make the data members public so that other classes can quickly access them. This is what makes C++ a fast language.

True

False

False

15
New cards

This program will compile and run just fine:

#include

int main()

{

cout << "Hello World\n";

return 0;

}

True

False

False

16
New cards

What kind of code do computers understand?

Bro Code

Source Code

Machine Code

Assembly Code

Machine Code

17
New cards

What is the linux command to show the contents of a file?

cat

show

There are 2 correct answers listed

more

There are 2 correct answers listed

(cat and more)

18
New cards

What linux command is used to print "Hello World" on the terminal

push Hello World

type Hello World

echo Hello World

print Hello World

echo Hello World

19
New cards

Suppose there is a class called Card which is a playing card and suppose I have a vector of cards called deck. Consider the following code segment:

vector deck; // create a vector of cards

Card c1('A','S'); // create a card

????? // add the card to the deck

What is the statement that will add the card to the deck?

deck = c1;

deck.push_back(c1);

deck.put(c1);

deck.add(c1);

deck.push_back(c1);

20
New cards

What is the name of the linux root directory?

/

./

../

root

/

21
New cards

Suppose I have a file numbers.dat with the numbers 1 through 1000 sorted, one number per line. What will be printed on the screen if I type this command sequence:

$ more numbers.dat | tail -100 | head -20 | tail -1

921

920

none of these answers is correct

901

920

22
New cards

Consider the following code segment in C++:

int A[ ] = {0, 1, 2, 3, 4, 5};

int *ptr = A;

How would I print 5 to the screen?

cout << ptr[5];

cout << *ptr[5];

cout << ptr * 5;

cout << ptr + 5;

cout << ptr[5];

23
New cards

Consider this code segment:

int x = 10;

int y = 20;

int z = mystery(x, y);

cout << z << "/" << x + y;

Also consider this function:

int mystery(int a, int &b)

{

a += 5;

b += 5;

return a + b;

}

What prints to the screen?

40/30

40/35

30/40

35/40

40/35

24
New cards

What is wrong with the following C++ program:

#include

using namespace std;

int main()

{

int x=3, y=5; // line 1

int * ptr; // line 2

int *ptr2 = &y ; // line 3

y = x; // line 4

ptr = & x; // line 5

cout << x << y << ptr;

return 0;

}

line 2 is wrong

line 3 is wrong

line 5 is wrong

nothing is wrong

nothing is wrong

25
New cards

Consider the following C++ code:

int a = 10;

int *ptr = &a;

cout << ptr;

What is printed out?

the number 10

the memory address of ptr

the contents of a

the memory address of a

the memory address of a

26
New cards

Consider the following segment of code in C++:

int nums[10] = {1,2,3,4,5,6,7,8,9,10};

printArray(nums);

Also consider the this function:

void printArray(int n[ ])

{

for(int i=0, i < n.size(), i++)

cout << n[i];

}

How many numbers will the printArray( ) function actually print out?

10

all the numbers in the array

the correct answer is not listed

1

the correct answer is not listed

27
New cards

Consider the following program. What will is the output?

#include

#include

using namespace std;

int main()

{

vector v;

for (auto i=0; i

15

28
New cards

Consider this code segment:

int nums[10];

nums[10] = 999;

Which of the following statements is true?

There is nothing wrong with the code.

The code will compile but there is something wrong with this code.

The code will not compile.

C++ is a dangerous motorcycle and you could be mortally wounded if you try to use it!!!

The code will compile but there is something wrong with this code

29
New cards

Using linux commands, how would I find out more about the wc command?

more wc

help wc

man wc

list wc

man wc

30
New cards

What can be understood from the following Linux command and result:

$ time sort numbers.dat > sorted.out &

real 0m1.593s

user 0m5.128s

sys 0m0.184s

The command took about 6.9 seconds to run (1.6 + 5.1 + 0.2).

The command took about 1.6 seconds to run.

The command took about 5.1 seconds to run.

The command took about 0.2 seconds to run.

The command took about 1.6 seconds to run

31
New cards

Assume the following C++ code segment:

struct student

{

string name;

int age;

char grade;

};

student s1, *sptr;

sptr = &s1;

s1.name = "MasterGold";

What code would you use to set Master Gold's grade to A?

The correct answer is not listed

sptr.grade = 'A'

s1->grade = 'A';

MasterGold->grade = 'A';

The correct answer is not listed.

32
New cards

Assume the following C++ code segment:

struct student

{

string name;

int age;

char grade;

};

student s1, *sptr;

sptr = &s1;

s1.name = "MasterGold";

What code would you use to set Master Gold's age to 49?

student.age = 49;

sptr->age = 49;

sptr.age = 49;

The correct answer is not listed.

sptr->age = 49;

33
New cards

The function pthread_create( ) has how many parameters?

1

3

4

2

4

34
New cards

Consider the following C++ code segment:

char word[10] = "matrix";

cout << strlen(word);

What will be printed to the screen?

The correct answer is not listed

10

matrix

6

6

35
New cards

The function pthread_create( ) allows a program to have multiple threads running concurrently.

True

False

True

36
New cards

Consider the following C++ code segment:

char name[15] = "PonyExpress";

char * cptr = name;

name = "cowboy";

cout << name;

Which of the following is true:

You can't assign "cowboy" to name

There is overflow on the first line

Cowboys can't be in the Pony Express

You can't assign an array to a pointer

You can't assign "cowboy" to name

37
New cards

In which c++ library is strlen( ) found?

The correct answer is not listed.

38
New cards

What is another name for "null terminated character array"

word

The correct answer is not listed

container

C-string

C-string

39
New cards

The following C++ function receives an array of integers and a particular index in that array. Index is within the bounds of the passed array. The cout statement will correctly print the desired element. Which of the answers will print the same correct output that is printed by this function?

int showElement(int A[ ], int index)

{

cout << A[index];

}

cout << *(A + index);

cout << &A + index;

cout << &A[index];

cout << *A + index;

cout << *(A + index);

40
New cards

Consider the following valid C++ function:

void func(char * ptr)

{

cout << ptr;

}

What is the passing mode used in the function to pass the parameter ptr?

pass by reference

pass by linkage

pass by touchdown

pass by value

pass by value