Appendix C: Answers to Review Questions


Chapter 1

1.

What is a variable?

a place in memory set aside to hold data of a particular type. the variable name is simply a reference to that section of memory.

2.

What is a statement?

a line of code that performs some action

3.

Which of the following are legal names for variables in C++?

Firstname

&salary No

x

y

first@name

 firstname yes & salary no x yes y yes first@name no

4.

All valid C++ statements end with a what?

a semicolon (;)

5.

What type of value must the main function return?

an int

6.

What is the purpose of brackets?

to establish boundaries for a block of code

7.

What is a local variable?

a variable declared within some block of code. that variable is only good inside that block of code.

8.

What is a global variable?

a variable declared outside any block of code. that means it is good throughout all functions in that file.

9.

If a function does not return anything, then what do you put for its return type?

 void

10.

What is a parameter?

a variable that is passed to a function

Answers

1.

A place in memory set aside to hold data of a particular type. The variable name is simply a reference to that section of memory.

2.

A line of code that performs some action

3.

Firstname Yes

&salary No

x Yes

y Yes

first@name No

4.

A semicolon (;)

5.

An int

6.

To establish boundaries for a block of code

7.

A variable declared within some block of code. That variable is only good inside that block of code.

8.

A variable declared outside any block of code. That means it is good throughout all functions in that file.

9.

void

10.

A variable that is passed to a function




C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net