C++ test 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The null terminator stands for the ASCII code

0.

Assume that str1 and str2 are objects of the string class. The proper expression to use when comparing them for equality is

B) str1 == str2.

Indirect recursion means that a function calls itself several times.

False

The C++ compiler performs strict array bounds checking whenever an array of characters is being accessed.

False

To declare a C-string, you should use the type expression string *.

False

The ________ algorithm uses recursion to sort an array.

Quicksort

A recursive function is a function that calls itself.

True

Any algorithm that can be coded with recursion can also be coded using a loop.

True

By being able to pass arrays as arguments, you can write your own functions for processing C-strings

True

It is possible to implement a string class by using a dynamically allocated array of characters.

True

The string class append member function str.append(s) attaches a string s to the end of str.

True

When using the strcat function, you must be careful not to overflow the bounds of the array allocated for the target string.

True

An array of characters ending with the null terminator is called

a C-String

The expression strcmp("ab", "cde") returns

a negative interger

A recursive function should be designed to stop making recursive calls when it reaches its

base case.

The string class member function ________ returns the C-string value of the string object.

c_str()

Recursion can be used to

compute factorials., find the greatest common divisor of two integers (GCD)., can be used to divide problems into smaller parts of the same type., implement sorting algorithms.

The string class overloads the += operator to perform

concatenation of two strings.

The number of times a recursive function calls itself is called the ________ of recursion.

depth

When a function A calls a function B, which in turn calls A, we have

indirect recursion.

Which statements convert the string "10" to the integer value 10?

istringstream istr("10"); int x; istr >> x;

The string class member function ________ will return the number of characters in the string object.

length()

Assume that str1 and str2 are variables of type C-string. The proper expression to use when comparing them for equality is

strcmp(str1, str2) == 0.

The ________ function converts an integer to a string and returns the string value.

string to_string(int i)

The ________ function accepts a C-string as an argument and returns the length of the string (not including the null terminator).

strlen

A library function that looks for the occurrence of one string inside another is

the string class member function find(string s, int pos).

The programmer must ensure that a recursive function does not become

trapped in an infinite chain of recursive calls.

The strcpy function's arguments are

two pointers to char.

The quicksort algorithm works on the basis of

two sublists and a pivot.

A good way to convert a value of type double to a string is

use the ostringstream class.


Set pelajaran terkait

IB SEHS - OPTION A (In my own words... sorta)

View Set

Home Care Instructions for Removable Prosthesis

View Set

CRPC | Designing Optimal Retirement Income Streams

View Set

Torts MC Midterm (Negligence) Practice Questions

View Set

Beginning and End of Week 1 quiz

View Set

Module 12 Textbook & Quiz | ITE-249-02 Authentication

View Set

Chapter 25: The Fetal Face & Neck

View Set