12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Workshop<br />

Wad<strong>in</strong>g In Deeper<br />

The Workshop conta<strong>in</strong>s quiz questions to help you solidify your understand<strong>in</strong>g of the<br />

material covered and exercises to provide you with experience <strong>in</strong> us<strong>in</strong>g what you have learned.<br />

You can f<strong>in</strong>d answers to the quiz questions <strong>in</strong> Appendix A, “Answers to Quiz Questions.”<br />

Q&A<br />

Quiz<br />

Q How many levels deep can I nest if statements?<br />

A There’s no limit. There is, however, a practical limit. If you have too many nested<br />

if statements it gets very hard to keep all those brackets straight!<br />

Q Will loops automatically term<strong>in</strong>ate if someth<strong>in</strong>g goes wrong?<br />

A No. If you accidentally write an endless loop, that loop will cont<strong>in</strong>ue to run until<br />

you do someth<strong>in</strong>g to stop it. You can stop a program stuck <strong>in</strong> an endless loop by<br />

br<strong>in</strong>g<strong>in</strong>g up the W<strong>in</strong>dows Task Manager (or the Close Program box) and end<strong>in</strong>g<br />

the errant task. If you executed the program via the <strong>C++</strong>Builder IDE, you can<br />

choose Run | Reset Program from the ma<strong>in</strong> menu to kill the program.<br />

Q Does a switch statement have to <strong>in</strong>clude a default section?<br />

A No. The default section is optional.<br />

Q Can I have more than one variable with the same name?<br />

A Yes, provided they are <strong>in</strong> different scopes. You cannot have two variables named x<br />

that are both declared with<strong>in</strong> a code block. You can, however, have a global<br />

variable named x and a local variable with the same name.<br />

Q Can I use a structure by itself, without an object?<br />

A No. Before you can use a structure you have to create an <strong>in</strong>stance of the structure<br />

and access the structure through the <strong>in</strong>stance variable.<br />

1. What statements are executed <strong>in</strong> the event that an if expression evaluates to true?<br />

2. What do the three parameters of a for statement represent?<br />

3. Besides syntax, what is the difference between a while loop and a do-while loop?<br />

4. What do the break and cont<strong>in</strong>ue statements do?<br />

5. What is a global variable?<br />

6. Can a structure conta<strong>in</strong> a mixture of data types (char, <strong>in</strong>t, long, and so on)?<br />

65<br />

2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!