|
Write a statement that will set the integer variable Length to the length
of the string named My_String.
|
A |
if (Last_Name==Search-Name)
cout « "FOUND";
else
cout « "NOT FOUND"
|
|
Write a simple programming structure that will compare the string named
My_Stringl and the string named My_String2 and print the message Equal if they are the
same and Not Equal if they are not.
|
B |
strcat (Address, " ") ;
|
|
Write a statement that will add the contents of the character array
Last_Name to the character array First_Name.
|
C |
Info_String += New_Info;
|
|
Write a statement that will put a blank space at the end of the string in
the character array named Address.
|
D |
Length = atoi(Distance);
|
|
Write a simple structure that will compare a string in the character array
named Last-Name and the string in the character array named Given. If Last-Name comes
first alphabetically, display the message IN ORDER and if not display the message OUT OF
ORDER.
|
E |
if(strcmp(My_Stringl, My_String2)==O)
cout « "Equal";
else
cout « "Not Equal";
|
|
Using the string class, write a code segment that will compare two
strings, La.st-Name, Sea.rch-Name. If they are equal, print out FOUND, otherwise print out
NOT FOUND.
|
F |
These operands are overloaded inside the class definition because they
need access to all of the private data in the class.
|
|
Using the string class, write a statement that will assign the string
Owner to the string New-Owner.
|
G |
cout « str_amount.converttofloat();
|
|
Using the string class, write a statement that will append a character
array named New_Info onto an existing string called Info_String.
|
H |
Length = strlen(My-String);
|
|
4. Using the string class, write a statement that will return the length
of the string Person and store it in the integer variable Length.
|
I |
sum = 5.00 + atof(Cost);
|
|
In the string class, why are the =, [], and += operators overloaded inside
the class definition rather than outside of the class definition?
|
J |
if(strcmp(Last-Name, Given)cout«"IN ORDER";
else
cout«"OUT OF ORDER";
|
|
Write a statement that will convert the contents of the character array
Distance to an integer and store the value in the integer variable Length.
|
K |
strcat(First_Name, Last_Name);
|
|
Write a statement that will convert the contents of the character array
Cost (declared below) to a floating point value, add 5.00 to the value, and store the
result in a variable named sum.
char Cost = "4.25";
|
L |
amount = str_amount.converttofloat();
|
|
Assuming that the string class has been modified to support integer and
floating-point conversion using the member functions shown below, write a statement that
uses the string class to convert the contents of a string named in_value to an integer and
store the result in an integer named value.
int oostring::converttoint() const
{ return(atoi(myCString));
}
double oostring::converttofloat() const
return(atof(myCString)); }
|
M |
New_Owner=Owner;
|
|
Using the modified class from the question above, write a statement that
uses the string class to convert the contents of a string named str_amount to a variable
of type double named amount.
|
N |
value = in_value.converttoint();
|
|
Using the modified class from the question above, write a statement that
uses the string class to output the numeric value of the string named str_amount to the
screen.
|
O |
Length = Person.length();
|