Answers 863
F
return 0;
}
void print_letter2(void)
{
char letter2 = ‘=’;
int ctr; /* this is a local variable */
/* it is different from ctr in main() */
for( ctr = 0; ctr < 2; ctr++ )
printf( “%c”, letter2 );
}
Answers for Day 13
Quiz
- Never. (Unless you are very careful.)
- When a breakstatement is encountered, execution immediately exits the for,
do...while,orwhileloop that contains the break. When a continuestatement is
encountered, the next iteration of the enclosing loop begins immediately. - An infinite loop executes forever. You create one by writing a for,do...while,or
whileloop with a test condition that is always true. - Execution terminates when the program reaches the end of main()or the exit()
function is called. - The expression in a switchstatement can evaluate to a long,int,orcharvalue.
- The defaultstatement is a case in a switchstatement. When the expression in the
switchstatement evaluates to a value that doesn’t have a matching case, control
goes to the default case. - The exit()function causes the program to end. A value can be passed to the
exit()function. This value is returned to the operating system. - The system()function executes a command at the operating system level.
Exercises
1.continue;
2.break;
- For a DOS system, the answer would be
system(“dir”); - This code fragment is correct. You don’t need a breakstatement after the printf()
for‘N’, because the switchstatement ends anyway.
49 448201x-APP F 8/13/02 11:22 AM Page 863