COP 3014 Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The null terminator stands for ASCII code 1000 100 57 None of these 0

0

What is the value stored in num after the following statement executes?num = atoi("1000"); 1000 999 "1 thousand" "1000" None of these

1000

Using a linear search to find a value that is stored in the last element of an array that contains 20,000 elements, ________ elements must be compared. 20,000 2,000 only half only the first two None of these

20,000

What is the output after the following code executes?int numerator = 5;int denominator = 25;int temp = 0;temp = numerator;numerator = denominator;denominator = temp;cout << numerator << "/" << denominator << " = " <<(numerator/denominator) << endl; 5/25 = 0 25/5 = 5 5/25 = 0.2 25/5 = 25/5 5/25 = numerator/denominator

25/5 = 5

Given the string shown below, if the delimiter is a space, how many tokens are in the string? "Tony's email address is [email protected]" 9 6 7 4 5

5

The escape sequence that represents the null terminator is \t None of these nullptr \n \0

\0

Data that is to be sorted in ascending order is ordered from lowest value to highest value with a binary search algorithm from highest value to lowest value by identifying the middle value and going up and down from there None of these

from the lowest value to highest value

Passing a structure as a constant reference parameter to a function will always change the structure's members None of these can potentially result in changes to the structure's members guarantees not to result in changes to the structure's members

guarantees not to result in changes to the structure's members

A structure pointer contains the address of a structure variable the dereferenced address of a structure tag the name and address of the structure tag the address of a structure tag None of these

the address of a structure variable

The function that converts a C-string to an integer and returns the integer value is strint None of these atoi atoint strtoint

atoi

Which of the following converts the string "10" to the integer value 10? itoa("ten"); itoa(10); None of these atoi("10"); atoi("ten");

atoi("10");

A ________ search is more efficient than a ________ search. None of these linear, binary character, string integer, double binary, linear

binary, linear

A ________ search is more efficient than a ________ search. linear, binary integer, double binary, linear None of these character, string

binary, linear

The expression being tested by the statement shown below will evaluate to true if var1 is ________.if (!isdigit(var1)) an alphabetic character None of these a symbol such as $ or & both A and C 9

both A and C an alphabetic character a symbol such as $ or &

What does the following statement do?double *num2; Initializes a pointer variable named num2 Declares a pointer variable named num2 Declares a double variable named num2 Declares and initializes a pointer variable named num2 None of these

declares a pointer variable named num2

When an array is sorted from highest to lowest, it is said to be in reverse order None of these ascending order descending order forward order

descending order

A declaration for an enumerated type begins with the ________ key word. enum_type None of these enumerated ENUM enum

enum

With pointer variables you can ________ manipulate data stored in other variables. all of these none of these never indirectly seldom

indirectly

Assume you have two integer variables, num1 and num2. Which of the following is the correct way to swap the values in these two variables? int temp = num1;num2 = temp;temp = num2;num1 = temp; None of these int temp = num1;num2 = num1;num1 = num2; int temp = num2;num2 = num1;num1 = temp; num1 = num2;num2 = num1;

int temp = num2;num2 = num1;num1 = temp;

To test whether a character is a numeric digit character, use the ________ function. isnumeric isnumber isdigit notAlpha None of these

isdigit

Which of the following will return true if the argument is a printable character other than a digit, letter, or space? ispunct isnotdls ischar isprint None of these

ispunct

To determine whether a character entered is whitespace, use the ________ function. iswhite isspace None of these isblank iswhitespace

isspace

A(n) ________ search uses a loop to sequentially step through an array. unary binary linear None of these relative

linear

What is the output of the following statement?cout << tolower(toupper('Z')) << endl; lowercase z a lowercase z followed by an uppercase Z uppercase Z None of these a compiler error

lowercase z

A binary search begins with the ________ element of an array. largest first None of these last middle

middle

To help prevent memory leaks from occurring in C++11, a ________ automatically deletes a chunk of dynamically allocated memory when the memory is no longer being used. smart pointer dereferenced pointer null pointer none of these

smart pointer

Array elements must be ________ before a binary search can be performed. summed None of these positive integers sorted set to zero

sorted

Algorithms used to arrange random data in some order are ________ algorithms. None of these binary search standard search sorting linear

sorting

The ________ function concatenates the contents of one C-string with another C-string. strcat strcopy strappend None of these stradd

strcat

The function that accepts pointers to two C-strings and an integer argument that indicates how many characters to copy from the second string to the first is strcpy strncpy strintcpy None of these copystring

strncpy

In C++11, you can use a new type of enum known as a(n) ________ (also known as an enum class) to have multiple enumerators with the same name, within the same scope. multi-cast enum strongly typed enum auto enum universal enum None of these

strongly typed enum

A library function that can find one C-string inside another is None of these strstr strcmp strfind strsearch

strstr

If a variable uses more than one byte of memory, for pointer purposes its address is the average of all the addresses used to store that variable the address of the first byte of storage None of these the address of the last byte of storage the address of the second byte of storage

the address of the first byte of storage

Which of the following will allow you to access structure members? the #include directive the structure access operator the getmember function the dot operator None of these

the dot operator

What will the following code output?int *numbers = new int[5];for (int i = 0; i <= 4; i++)*(numbers + i) = i;cout << numbers[2] << endl; 2 3 0 1

2

Given the following structure declaration, idNum is struct Employee{string name;int idNum;}; an array a member None of these a tag

a member

A pointer variable is designed to store only floating-point values a memory address None of these an integer any legal C++ value

a memory address

Given the following structure declaration, Employee is struct Employee{string name;int idNum;}; None of these a member an array a tag

a tag

Every byte in the computer's memory is assigned a unique dynamic allocation pointer None of these name address

address

You may use a pointer to a structure as a function parameter function return type None of these All of these structure member

all of these function parameter function return type structure member

Which of the following can be used as pointers? none of these array names key words numeric constants

array names

The function that accepts a C-string containing a number as its argument and returns the integer equivalent is int_from atoi None of these strToInt itoa

atoi

Regardless of the algorithm being used, a search through an array is always performed None of these from highest to lowest element beginning with the middle element using a binary search algorithm from lowest to highest element

none of these

The name of a structure is referred to as its None of these data type parameter argument tag

none of these

When you pass a pointer as an argument to a function, you must dereference the pointer value in the function prototype use the #include statement none of these declare the pointer value again in the function call not dereference the pointer in the function's body

none of these

In C++ a C-string is a sequence of characters stored in consecutive memory, terminated by a semicolon space null character None of these period

null character

If a is a structure variable and p, a pointer, is a member of the structure, what will the following statement do?cout << *a.p; output the dereferenced value pointed to by p result in a compiler error None of these output the address stored in p output the value stored in a

output the dereferenced value pointed to by p

After the code shown executes, which of the following statements is TRUE? int numbers[] = {0, 1, 2, 3, 4};int *ptr = numbers;ptr++; ptr will hold the address of numbers[1] ptr will hold the address of numbers[0] ptr will hold the address of the second byte within the element numbers[0] this code will not compile

ptr will hold the address of numbers[1]

A ________ algorithm is a method of locating a specific item of information in a larger collection of data. sort search linear standard None of these

search

The following is the pseudocode for which type of algorithm? For start = each array subscript, from the first to the next-to-lastminIndex = startminValue = array[start]For index = start + 1 To size - 1If array[index] < minValueminValue = array[index]minIndex = indexEnd IfEnd Forswap array[minIndex] with array[start]End For bubble sort selection sort bubble search binary sort None of these

selection sort

The following is the pseudocode for which type of algorithm?For start = each array subscript, from the first to the next-to-lastminIndex = startminValue = array[start]For index = start + 1 To size - 1If array[index] < minValueminValue = array[index]minIndex = indexEnd IfEnd Forswap array[minIndex] with array[start]End For None of these selection sort bubble sort bubble search binary sort

selection sort

The ________ sort usually performs fewer exchanges than the ________ sort. ANSI, ASCII bubble, selection binary, linear selection, bubble None of these

selection, bubble

In C++11, assuming mychar is a char variable and mystring is a string, what is the value of mychar after the following statement executes? mychar = mystring.front(); nothing, the function is missing an argument the ASCII value of the first character of mystring the first character of mystring this will cause a compiler error

the first character of mystring

The ________ is adequate for searching through small arrays. bubble sort unary search binary search None of these the linear search

the linear search

The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function? void swap(int num1, int num2){int temp = num2;num2 = num1;num1 = temp;} The swap function must use reference parameters. You must first initialize temp to 0 before using it. The last line should be temp = num1. Nothing is wrong with this function. The variable temp should first be set to num1, not num2.

the swap function must use reference parameters

The ________ function will change a character argument from lowercase to uppercase. toupper tolarge None of these isupper fromlower

toupper

The arguments of the strcpy function are one array and one pointer three pointers two addresses None of these two C-strings

two addresses

What is the result after the following statement executes?char var1 = tolower('A'); the character A is output to the monitor var1 stores the character value 'A' None of these var1 stores the ASCII value for lowercase 'a' the character a is output to the monitor

var1 stores the ASCII value for lowercase 'a'


Kaugnay na mga set ng pag-aaral

ENT 2113- Ron Bolen Final Exam study Set (Spring 2022)

View Set

Quiz 6: HACCP Principle 1 Hazard Analysis

View Set