
1. The integer and floating point types in C++ are considered to be
_________________ types.
a. simple b. address c. structured
2. The struct and union types in C++ are considered to be _________________ types.
a. simple b. address c. structured
3. Give the values of each of the following expressions
a. 27 + 8/5 -7
b. 27 + 8 %5 -7
c. 27 + 8.0/5 - 7
4. Suppose str1 and str2 are string variables and str1 = “You should start with logic” and
str2= “th”. What is the value of each of the following expressions.
a. str1.substr(10, 5);
b. str1.substr(str1.find(“logic”),3)
c. str1.substr(15,8).find(str2.substr(0,1)
5. Implement an int function that has three int parameters. The first is named hours, the
second minutes and the third seconds. The function returns the number of seconds
represented by the parameters. For example, if hours contains 2, minutes contains 20, and
seconds contains 12, the function should return 8412.
6. The following code segment is supposed to write out the odd numbers from 1 to 19.
What does it actually output? Change the code to work correctly.
number = 1;
while( number < 10 )
{
number ++;
cout << number*2 -1 << “ “;
}