}
return 0;
}
- The previous answers already are executable programs. The only change that needs
to be made is in the final printf(). To print each value separated by a tab, change
theprintf()statement to the following:
printf( “%d\t”, array[x]); - You can’t have quotes within quotes. To print quotes within quotes, you must use
the escape character \”. Additionally, you must include a single slash at the end of
the first line in order to have the text continued to the second line. The following is
the corrected version:
printf( “Jack said, \”Peter Piper picked a peck of pickled \
peppers.\””); - This listing has three errors. The first is the lack of quotes in the printf()state-
ment. The second is the missing address-of operator in the answervariable in the
scanf(). The final error is also in the scanf()statement. Instead of “%f”, it should
have “%d”, becauseansweris a type intvariable, not a type float. The following
is corrected:
int get_1_or_2( void )
{
int answer = 0;
while( answer < 1 || answer > 2 )
{
printf(“Enter 1 for Yes, 2 for No “); /* corrected */
scanf( “%d”, &answer ); /* corrected */
}
return answer;
}
- Here is the completed print_report()function for Listing 7.1:
void print_report( void )
{
printf( “\nSAMPLE REPORT” );
printf( “\n\nSequence\tMeaning” );
printf( “\n=========\t=======” );
printf( “\n\a\t\tBell (alert)” );
printf( “\n\b\t\tBackspace” );
printf( “\n\f\t\tForm feed” );
printf( “\n\n\t\tNew line” );
printf( “\n\r\t\tCarriage Return” );
printf( “\n\t\t\tHorizontal tab” );
844 Appendix F
49 448201x-APP F 8/13/02 11:22 AM Page 844