1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
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
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
In the C++ language when building a class, header files (.h) must be separate from implementation files (.cpp)
a)True
b)False
b
This program will compile and run just fine:
#include
int main()
{
cout << "Hello World\n";
}
a)True
b)False
b
What kind of code do computers understand?
a) Assembly Code
b) Bro Code
c) Machine Code
d) Source Code
c
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
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
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
According to NUMA architecture, all memory in a computer can be accessed and the retrieval times are constant.
a)True
b)False
b
Suppose I have a vector that I want to pass to a sort( ) function.
vector
// 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
b) void sort (vector
c) the correct answer is not shown
d) void sort ( vector
d
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;
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
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
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
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
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
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
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
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
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
The function pthread_create( ) allows a program to have multiple threads running concurrently.
a) True
b) False
a
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
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
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
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
The function pthread_create( ) has how many parameters?
a) 2
b) 4
c) 3
d) 1
b
What is another name for "null terminated character array"
a) C-string
b) container
c) The correct answer is not listed
d) word
a
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
In which c++ library is strlen( ) found?
a)
b) The correct answer is not listed.
c)
d)
d
What is the linux command to print working directory, shows which directory you are currently in
pwd
What is the linux command changes directory
cd / location
What is the linux command returns to home directory
cd ~
What is the linux command copies a file(s)
cp
What is the linux command list files in directory
ls
What is the linux command list files and hidden files in directory
ls -a
What is the linux command displays information about a command
man
What is the linux command concatenate/read the data on a file, quicker than opening file
cat
What is the linux command to print specific text on the terminal window
echo
What is the linux command displays the first 10 lines of a file
head
What is the linux command lets users operate apps as a different user, root is default, "super user do"
sudo
What is the linux command to view a specific file
more
What is the linux command to removes a particular file
rm
What is the linux command to move a file from one directory to another
mv
What is the linux command to displays a list groups of users/information, describes membership of a user
groups