You're doing something like this:
Code:
while(x != 0)
{
if(x == 0) ...
}
This clearly is problematic.
I'd recommend working out, on paper, how this program should flow. Once you've satisfied yourself that it makes sense, work on translating it to C. The desire to just sit down and code is strong, I know; but having a good design to follow will make your life easier, I promise.
I'd also like to discuss your comments. I suspect this is for a class, and you're required to use comments (which is a good thing); however, proper commenting is difficult to do. The goal in commenting should not be to translate C to English. Anybody reading the code already knows C; and if he doesn't, some comments aren't going to teach him the language.
Comments like the following do not add any information:
Code:
iPassengers++; /* increase the passengers */
printf( "Please type 1 for First Class.\n" ); /* prompt */
int iPassengers = 0, i; /* passengers set to zero */
int main( void ) /* function main begins program execution */
scanf( "%d" , &response ); /* read response from user */
All these comments merely explain what the code does; they're redundant. Nobody is going to be confused when they see “iPassengers++”. Instead, what you want your comments to do is explain, in more broad terms, what the code is doing. You might sketch out the algorithm you're using and why it was chosen, for example.
Here's a comment from FreeBSD's syslogd:
Code:
/* Don't allow users to log kernel messages.
* NOTE: since LOG_KERN == 0 this will also match
* messages with no facility specified.
*/
if ((pri & LOG_FACMASK) == LOG_KERN && !KeepKernFac)
pri = LOG_MAKEPRI(LOG_USER, LOG_PRI(pri));
If you're not familiar with the code, what it's doing might not make sense, hence the first sentence. But even more important, I think, is the note: this is an excellent use of commenting, because it explains behavior that might otherwise be surprising. It's not clear at all from this code that no facility and a facility of kernel look identical. The comment here doesn't say “perform a bitwise and of pri with LOG_FACMASK and see if it equals LOG_KERN”, etc. That much is clear from the code. Rather, it explains what the code means.
It'll take time to learn proper commenting, and I'm much happier that you're over-commenting rather than under-commenting.