Chapter Eight

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

False

A function prototype must specify the name of a function and the name and type of each of its parameters. True or False?

True

A local variable can be referenced anywhere within the block in which it is declared. True or False?

False

Arguments can appear in any order as long as they have the correct types and C++ will figure out the correspondence. True or False?

The physical hiding of the source code

Define encapsulation

Reference parameters are used either for the direction of flow as Out or as an In/Out. Reference can be an Out or an In/Out parameter.

For which direction(s) of data flow do you use reference parameters?

True

Functions can be called from other functions in addition to main. True or False?

six

If a function has six parameters, how many arguments must appear in a call to the function?

In the function heading "age" and "level" are the value parameters while "name" and "salary" are the reference parameters.

In the following function heading, which parameters are value parameters and which are reference parameters? void ExamPrep (string& name, int age, float& salary, char level)

Its value will be changed without affecting the value of the argument passed. There exists two copies of data, one in value parameter and the other in argument. Parameters passed as copies of their arguments. So, any value may be passed as value parameter.

What happens if a function assigns a new value to a value parameter?

the location of the argument passed will be changed. Only one copy of the information exists. Reference parameter has the location of the argument.

What happens if it assigns a new value to a reference parameter?

The parameters x and y should be value parameters (do not add & to int for x and y)

What is wrong with the following code segment? void Power (int& x, int& y, int& result) { int result; result = 1; while (y > 0) { result = result * x; y--; } }

In line 3 it should be a reference parameter instead of a local variable (remove from segment)

What is wrong with the following functions? void Power (int x, int y) { int result; result = 1; while (y > 0) { result = result * x; y--; } }

The variable "result" should be a reference parameter instead of a value parameter (add & to int for result)

What is wrong with the following segment? void Power (int x, int y, int result) { result = 1; while (y > 0) { result = result * x; y--; } }

A void function heading begins with the word void. The function does not return any value. A return statement does not appear in the body of a void function.

What three things distinguish a void function from main?

The file must contain only integer values and the file should not be empty as the mean for empty dataset is undefined.

What would be the precondition for a function that reads a file of integers and returns their mean?

The name and the data type declarations were interchanged in their positions

What's wrong with this function prototype? void ExamPrep (phone& int, name string, age& int)

It returns to the calling function after executing the last statement in its block. A void function doesn't return any value to the calling function

When and to where does control return from a void function?


Ensembles d'études connexes

Physical Science Study Guide Chapter 12.3/12.4 Work And Energy

View Set

1340 PU ch 26: Caring for Clients with Cardiac Dysrhythmias

View Set

ASSESS Chapter 6 Chapter Problems

View Set

CORE MVC:::: C#/.NET/MVC/Core, ASP .Net Core Web Applications MVC, ASP.NET Core MVC 2, Spring Core, MVC, AOP, ASP Net Core MVC RESTful, C# MVC 5 / Core 2.0, ASP.NET Core MVC, ASP.NET Core MVC, ASP.NET Core MVC, ASP.NET Core MVC

View Set

Chapter 12: Sexual Orientation, Identity and Expressions:

View Set

THE NERVOUS SYSTEM- ATI TEAS NOTES

View Set

Chapter 11: Maternal Adaptation During Pregnancy (Prep U)

View Set