CECS 325 Midterm

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

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:38 PM on 10/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

44 Terms

1
New cards

What statement is true about he C++ language?

a) None of these answers are correct.

b) it is interpreted

c) It was invented in 1968

d) It is compiled

d

2
New cards

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

a) integer nums[20];

b) nums[20]

c) int nums = new int[20];

d) int nums[20];

d

3
New cards

In the C++ language when building a class, header files (.h) must be separate from implementation files (.cpp)

a)True

b)False

b

4
New cards

This program will compile and run just fine:

#include

int main()

{

cout << "Hello World\n";

}

a)True

b)False

b

5
New cards

What kind of code do computers understand?

a) Assembly Code

b) Bro Code

c) Machine Code

d) Source Code

c

6
New cards

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

a) cat

b) There are 2 correct answers listed

c) show

d) more

b

7
New cards

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

a) print Hello World

b) push Hello World

c) echo Hello World

d) type Hello World

c

8
New cards

What does Amdahl's law describe?

a) Programs can run faster if you use parallel processing

b) The sequential work will limit the speedup due to parallelism!

c) Moore was an optimist

d) The computing power will double every 18 months

b

9
New cards

According to NUMA architecture, all memory in a computer can be accessed and the retrieval times are constant.

a)True

b)False

b

10
New cards

Suppose I have a vector that I want to pass to a sort( ) function.

vector v;

// the potion of the code that fills the

// vector is not shown

sort( v );

// I expect the vector to be sorted here

What does the signature of the sort function look like to make sure the vector will be sorted when it returns from the sort function?

a) void sort (vector vec)

b) void sort (vector * vec)

c) the correct answer is not shown

d) void sort ( vector & vec)

d

11
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?

a) cout << *ptr[5];

b) cout << ptr[5];

c) cout << ptr * 5;

d) cout << ptr + 5;

12
New cards

Consider this code segment:

int nums[10];

nums[10] = 999;

Which of the following statements is true?

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

b) There is nothing wrong with the code

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

d) The code will not compile.

c

13
New cards

Consider the following C++ code:

int a = 10;

int *ptr = &a;

cout << ptr;

What is printed out?

a) the memory address of a

b) the contents of a

c) the number 10

d) the memory address of ptr

a

14
New cards

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

a) list wc

b) man wc

c) more wc

d) help wc

b

15
New cards

When a C++ program runs, and dynamic memory is needed, where does the allocated dynamic memory live in memory?

a) ram

b) heap

c) stack

d) register

b

16
New cards

Suppose I have a file numbers.dat with the number 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

a) 901

b) none of these answers is correct

c) 920

d) 921

c

17
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?

a) 40/35

b) 40/30

c) 30/40

d) 35/40

a

18
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 num[ ])

{

for(int i=0, i

d

19
New cards

The fibonacci function is a recursive function. Each time the function gets called in a recursive loop, what type of memory is used to store the contents and state of the program?

a) stack

b) ram

d) register

e) heap

a

20
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?

a) pass by touchdown

b) pass by reference

c) pass by linkage

d) pass by value

d

21
New cards

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

a) True

b) False

a

22
New cards

Consider the following C++ code segment:

char word[10] = "matrix";

cout << strlen(word);

What will be printed to the screen?

a) 6

b) 10

c) matrix

d) The correct answer is not listed

a

23
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?

a) MasterGold->grade = 'A';

b) The correct answer is not listed

c) s1->grade = 'A';

d) sptr.grade = 'A'

b

24
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?

a) student.age = 49;

b) The correct answer is not listed.

c) sptr.age = 49;

d) sptr->age = 49;

d

25
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:

a) Cowboys can't be in the Pony Express

b) You can't assign "cowboy" to name

c) There is overflow on the first line

d) You can't assign an array to a pointer

b

26
New cards

The function pthread_create( ) has how many parameters?

a) 2

b) 4

c) 3

d) 1

b

27
New cards

What is another name for "null terminated character array"

a) C-string

b) container

c) The correct answer is not listed

d) word

a

28
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?

int showElement(int A[ ], int index)

{

cout << A[index];

}

a) cout << &A + index;

b) cout << *A + index;

c) cout << *(A + index);

d) cout << &A[index];

c

29
New cards

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

a)

b) The correct answer is not listed.

c)

d)

d

30
New cards

What is the linux command to print working directory, shows which directory you are currently in

pwd

31
New cards

What is the linux command changes directory

cd / location

32
New cards

What is the linux command returns to home directory

cd ~

33
New cards

What is the linux command copies a file(s)

cp

34
New cards

What is the linux command list files in directory

ls

35
New cards

What is the linux command list files and hidden files in directory

ls -a

36
New cards

What is the linux command displays information about a command

man

37
New cards

What is the linux command concatenate/read the data on a file, quicker than opening file

cat

38
New cards

What is the linux command to print specific text on the terminal window

echo

39
New cards

What is the linux command displays the first 10 lines of a file

head

40
New cards

What is the linux command lets users operate apps as a different user, root is default, "super user do"

sudo

41
New cards

What is the linux command to view a specific file

more

42
New cards

What is the linux command to removes a particular file

rm

43
New cards

What is the linux command to move a file from one directory to another

mv

44
New cards

What is the linux command to displays a list groups of users/information, describes membership of a user

groups