CECS 325 Quiz 1, 2, 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

What Linux command is used to generate information about memory usage?

free

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

int nums[20];

What statement is true about he C++ language?

it is compiled

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?

sptr->age = 49;

What is the name of the linux root directory?

/

The function pthread_create( ) has how many parameters? 2 3 4 1

4

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/35

Consider the following C++ code segment: char word[10] = "matrix"; cout << strlen(word); What will be printed to the screen?

6

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

920

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

<cstring>

What is another name for "null terminated character array"

C-string

Consider this code segment: int nums[10]; nums[10] = 999; Which of the following statements is true?

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

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 1.6 seconds to run

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

Which sorting algorithm is the fastest of those listed: Bubble Sort Insertion Sort Selection Sort

The listed algorithms are all about the same

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

True

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

In the C++ language when building a class, you must put the header information in a separate file than the implementation. T/F

False

This program will compile and run just fine T/F: #include <iostream> int main() { cout << "Hello World\n"; }

False

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. T/F

False

What kind of code do computers understand?

Machine Code

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

cat and more

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]; }

cout << *(A + index);

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];

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

echo Hello World

What is wrong with the following C++ program: #include <iostream>using namespace std; int main(){int x = 3; // line 1 int * ptr; // line 2 int & y; // line 3 y = x; // line 4 ptr = & x; // line 5 cout << x << y << ptr; return 0; }

line 3 is wrong

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

man wc

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 value

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?

the correct answer is not listed

Consider the following C++ code: int a = 10; int *ptr = &a; cout << ptr; What is printed out?

the memory address of a


Conjuntos de estudio relacionados

k12-9th Grade-Semester 2-History-unit 3.07-Quiz

View Set

F) Complete the medical term, based on its meaning as provided

View Set

Chapter 3 Behavioral science Practice question: Learning and memory

View Set

Chapter 7- Independent Contractor or Employee

View Set

FINAL- multiple choice 9, 10 , 11

View Set

ECON 302 Exam 2 Multiple Choice Question

View Set