1 / 32

Lecture 21:Quiz Review

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?.

cleave
Download Presentation

Lecture 21:Quiz Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 21:Quiz Review Introduction to Computer Science Spring 2006

  2. 1. What value is returned by the return statement above?

  3. 2. Given the following function prototype: int test(float, char); which of the following statements is valid?

  4. 3. To use the predefined function tolower, the program must include the header file _____.

  5. 4. A function prototype is _____.

  6. Given the following function prototype: double tryMe(double, double); • which of the following statements is valid? Assume that all variables are properly declared.

  7. Given the following function prototype: int myFunc(int, int); • which of the following statements is valid? Assume that all variables are properly declared.

  8. Given the above function, choose the output of the following statement: • cout<<mystery(9, 7);.

  9. 8. Given the above function, choose the output of the following statement: cout<<strange(4, 5);.

  10. Assume the above. The output of the statement: • cout<<static_cast<int>(tolower('B')); is _____.

  11. Given the function prototype: double testAlpha(int u, char v, double t); • which of the following statements is legal?

  12. 11. Which of the following function prototypes is valid?

  13. Given the function prototype: float test();, • which of the following statements is legal?

  14. 13. The output of the statement: cout<<pow(2,pow(3,1)); is _____.

  15. 14. The standard header file for the abs(x)function is _____.

  16. 15. Functions that do not have a data type are called _____ functions.

  17. 16.Which statement about prototypes and headers is true?

  18. 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.

  19. If an & is attached after the data type of a formal parameter, • then the formal parameter is a _____.

  20. What are the values of x and y after the statements above execute? • (Assume that variables are properly declared.)

  21. 20.What are the values of one and letter after the statements above execute?

  22. 21. parameters are useful when you want to return more than one value from a function.

  23. Suppose that printHeading is a function without any parameters. • Which of the following is a valid function heading?

  24. 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?

  25. Suppose that you are given the function definition above. • What is the output of the following statements? • printSomeThing(1); • printSomeThing(2); • printSomeThing(3);

  26. 25. What is the output of the program shown above?

  27. 26. Which of the following is a legal C++ function definition?

  28. 27. What is the output of the C++ code above?

  29. 28. Based on the function definition above, which of the following statements is valid?

  30. 29. Which of the following is a legal C++ function definition?

  31. 30. In C++, the scope resolution operator is _____.

  32. #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; }

More Related