320 likes | 526 Views
Lecture 21:Quiz Review. Introduction to Computer Science Spring 2006. 1. What value is returned by the return statement above?. 2. Given the following function prototype: int test(float, char); which of the following statements is valid?.
E N D
Lecture 21:Quiz Review Introduction to Computer Science Spring 2006
2. Given the following function prototype: int test(float, char); which of the following statements is valid?
3. To use the predefined function tolower, the program must include the header file _____.
Given the following function prototype: double tryMe(double, double); • which of the following statements is valid? Assume that all variables are properly declared.
Given the following function prototype: int myFunc(int, int); • which of the following statements is valid? Assume that all variables are properly declared.
Given the above function, choose the output of the following statement: • cout<<mystery(9, 7);.
8. Given the above function, choose the output of the following statement: cout<<strange(4, 5);.
Assume the above. The output of the statement: • cout<<static_cast<int>(tolower('B')); is _____.
Given the function prototype: double testAlpha(int u, char v, double t); • which of the following statements is legal?
Given the function prototype: float test();, • which of the following statements is legal?
13. The output of the statement: cout<<pow(2,pow(3,1)); is _____.
14. The standard header file for the abs(x)function is _____.
15. Functions that do not have a data type are called _____ functions.
A variable listed in a function call is known as a(n) _____ parameter. • A variable list in a header is known as a(n) _____ parameter.
If an & is attached after the data type of a formal parameter, • then the formal parameter is a _____.
What are the values of x and y after the statements above execute? • (Assume that variables are properly declared.)
20.What are the values of one and letter after the statements above execute?
21. parameters are useful when you want to return more than one value from a function.
Suppose that printHeading is a function without any parameters. • Which of the following is a valid function heading?
23. A void function accomplish has three parameters: a parameter u of the type int, a parameter v of the type double, and a parameter letter of the type char. The parameters u and letter need to pass their values out of the function and the parameter v is to only receive the value from the calling environment. Which of the following is a correct function heading?
Suppose that you are given the function definition above. • What is the output of the following statements? • printSomeThing(1); • printSomeThing(2); • printSomeThing(3);
26. Which of the following is a legal C++ function definition?
28. Based on the function definition above, which of the following statements is valid?
29. Which of the following is a legal C++ function definition?
#include <iostream> void CalcRectangle(double length, double width, double& circum, double& area); void PrintResult(double length, double width, double circum, double area); using namespace std; int main() { double length, width, circumference, area; cout<< “This program will calculate the circumference and area of the rectangle.” cout << “Please input the length and width of the rectangle: ” << endl; cin>>length >> width; CalcRectangle(length, width, circum, area); PrintResult(length, width, circum, area); return 0; } void CalcRectangle(double length, double width, double& circum, double& area); { circum = 2*(length+width); area = length * width; } void PrintResult(double length, double width, double circum, double area); { cout << “Length = ” << length <<endl; cout << “ Width = ”<< width <<endl; cout << “ Circumference = ” << circum <<endl; cout << “ Area = ”<< area <<endl; }