<http://lib.cnfolio.com/IndexQuestions>

Practice questions


These questions use the XML format according to the IMS Question & Test Interoperability Specification (IMS QTI). There are 6 question formats: multiple choice, true/false, multiple selections (more than 1 correct answer), ordered choices, inline multiple choice and text entry.



Next page
January 21, 2011

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.
9
7
10
5
Average rating is  
January 20, 2011

Introduction to Computing

01:  #include <string.h>
02:
03:  int main( void )
04:  {
05:    char password[ 512 ] = { '\0' };
06:    int index;
07:
08:    scanf( "%s", password );
09:
10:    for ( index = 0; index < strlen( password ); index = XX )
11:      password[ index ] = '*';
12:
13:    printf( "%s\n", password );
14:  }
The C program above is intended to replace the first and every other character of the input password with the character '*' (asterisk) and then display the modified password. At line 10, what should replace the XX placeholders?
Average rating is  
January 20, 2011

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?
Condition to find the lowest age in the array.
Condition to find the highest age in the array.
Condition to save the first value into the array.
Condition to clear all values in the array.
Average rating is  
January 20, 2011

Introduction to Computing

01:  #define LENGTH  50
02:
03:  int main( void )
04:  {
05:     double prices[ LENGTH ];
06:     double total = 0;
07:     int index;
08:
09:     for ( index = 0; index < XX; index++ )
10:     {
11:        scanf( "%lf", &prices[ index ] );
12:        total += prices[ index ];
13:     }
14:
15:     printf( "Average ticket price is %0.2lf", total / LENGTH );
16:  }
The C program above is intended to collect the ticket prices at 50 movie theatres, store them in an array and display the average ticket price. At line 9, what should replace the XX placeholders?
January 20, 2011

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?
&&
<=
||
>=
Average rating is  
Next page