# Need study help : /

Show 80 post(s) from this thread on one page
Page 2 of 3 First 123 Last
• 05-29-2003
RoD
thnx man, i am really going to enjoy the system dependant answer, seriously i cant wait till she marks it wrong.
• 05-29-2003
R.Stiltskin
Quote:

>>Explain the empty for loop

The counter is declared and initialized outside of the loop condition but referenced in conditional statements within the loop.
Wrong!!
"Empty" refers to the loop body. It just means that all the "action" is inside the parentheses. An example is:
Code:

`for( d=2; d < n && n / d != 0; d++ ) ;  // exits loop when d is a divisor of n (or d==n)`
Some people prefer this style:
Code:

```for( d=2; d < n && n / d != 0; d++ )     ;```
or this:
Code:

```for( d=2; d < n && n / d != 0; d++ )     {};```
to make it clear that it's not just a mistake.

Another name for this is a Null Statement.
• 05-29-2003
major_small
are you sure she's not looking for a relativity answer? as in:

unsigned<float<double
• 05-29-2003
R.Stiltskin
golfinguy4:

Are you sure? I've only seen for(;;); referred to as an infinite loop, same as while(1);

RoD:
Your post wasn't clear. Did teacher give for(;;) as an example?
• 05-29-2003
RoD
well i asked bout it today and i posted what she said she wanted.

Code:

```int i = 0; for (; i < 5; i++) { cout << "Runs 5 times!" << endl; }```
• 05-29-2003
major_small
that just means the LCV is initialized outside the loop...
• 05-29-2003
Zach L.
Quote:

98) List the data types and number of bytes each:

I have NO idea what the bytes are, but i listed char, int, double, float, bool, and string cuz we did those.
Missed a couple there... Off the top of my head,

char, int, short, long (each of which comes in signed and unsigned flavors)
bool, float, double, long double
• 05-29-2003
RoD
ya i only listed the ones she actually went over, cs2 sux for us
• 05-29-2003
R.Stiltskin
Well, I don't see how she can call that an empty anything. It's not empty. I see examples like the one I posted and examples like the one golfinguy posted both being called empty loops. They both make sense. I don't see any that look like your teacher's.

But she's marking the test. Too bad. Maybe you can ask her again, & show her our examples, before the test.

Good luck.
• 05-29-2003
Zach L.
Yeah, I'd say Stiltskin's is probably the most correct definition of empty loop... golfinguy's is probably technically an infinite loop, and not empty.

Also, on the structure of a program, I'd put something like this (in no particular order):

Pre-processor
Global-Scope/Namespace-Scope Constants (If your teacher is really picky, I suppose typedefs would go here too)
Function Prototypes
Class Declarations
Class Definitions
Driver (i.e. main)
• 05-29-2003
golfinguy4
Yeah, my empty loop was wrong. I misread what he wanted.
• 05-30-2003
RoD
well the test is in a few hours, and thnx to you guys im sure i'll pass it, thank ya.
• 05-30-2003
major_small
good luck ;-)
• 05-30-2003
RoD
110 question study guide, TWO questions on the actual test. god i really hate that \$\$\$\$\$
• 05-30-2003
Zach L.
And the real test was to see if you could keep your sanity after all that. ;)
Show 80 post(s) from this thread on one page
Page 2 of 3 First 123 Last