Introduction to Computing
01: #include <string.h>
02:
03: int main( void )
04: {
05: char text[ 512 ] = { '\0' };
06:
07: do
08: {
09: scanf( "%s", text );
10: } while ( strlen( text ) > 10 );
11: }
In the C program above, select the line containing the body of the loop.
Introduction to Computing
01: int main( void )
02: {
03: int age[ 40 ] = { 0 };
04: int youngest = -1;
05: int counter;
06:
07: for ( counter = 0; counter < 40; counter++ )
08: {
09: scanf( "%d", &age[ counter ] );
10: if ( ( age[ counter ] < youngest ) || ( youngest < 0 ) )
11: youngest = age[ counter ];
12: }
13:
14: printf( "The youngest age is %d", youngest );
15: }
The C program above is intended to collect the age of 40 people,
stores the values in an array and displays the youngest age. At line 10,
the expression on the right side of the or operator provides the condition for what?
Introduction to Computing
01: int main( void )
02: {
03: int guess;
04: while ( 1 )
05: {
06: scanf( "%d", &guess );
07: if ( ( guess == 45 ) XX ( guess == 47 ) )
08: break;
09: else
10: printf( "Try again\n" );
11: }
12: }
The C program above is intended to ask for an input number until the input
matches 45 or 47. The program also displays a message to inform the user when the
input does not match. At line 7, what should replace the XX placeholder?