thnx man, i am really going to enjoy the system dependant answer, seriously i cant wait till she marks it wrong.
Printable View
thnx man, i am really going to enjoy the system dependant answer, seriously i cant wait till she marks it wrong.
Wrong!!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.
"Empty" refers to the loop body. It just means that all the "action" is inside the parentheses. An example is:
Some people prefer this style:Code:for( d=2; d < n && n / d != 0; d++ ) ; // exits loop when d is a divisor of n (or d==n)
or this:Code:for( d=2; d < n && n / d != 0; d++ )
;
to make it clear that it's not just a mistake.Code:for( d=2; d < n && n / d != 0; d++ )
{};
Another name for this is a Null Statement.
are you sure she's not looking for a relativity answer? as in:
unsigned<float<double
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?
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;
}
that just means the LCV is initialized outside the loop...
Missed a couple there... Off the top of my head,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.
char, int, short, long (each of which comes in signed and unsigned flavors)
bool, float, double, long double
ya i only listed the ones she actually went over, cs2 sux for us
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.
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)
Yeah, my empty loop was wrong. I misread what he wanted.
well the test is in a few hours, and thnx to you guys im sure i'll pass it, thank ya.
good luck ;-)
110 question study guide, TWO questions on the actual test. god i really hate that $$$$$
And the real test was to see if you could keep your sanity after all that. ;)