Only use this if you have a forms compatible browser [Note: You must have an Internet connection in order to have these tests marked]
1. The function called menu which prints the text string "Menu choices", and does not pass any data back, and does not accept any data as parameters, looks like
function 1
void menu( void ) { printf("Menu choices"); }
function 2
int menu( void ) { printf("Menu choices"); }
function 3
int menu( char string[] ) { printf("%s", string); }
2. A function prototype for the above function looks like
int menu( char [] ); void menu( char [] ); void menu( void ); int menu( void );
3. A function called print which prints a text string passed to it as a parameter (ie, a character based array), looks like
int print( char string[] ) { printf("%s", string); }
void print( char string[] ) { printf("Menu choices"); }
void print( char string[] ) { printf("%s", string); }
4. A function prototype for the above function print looks like
int print( char [] ); void print( char [] ); void print( void ); int print( void );
5. A function called total, totals the sum of an integer array passed to it (as the first parameter) and returns the total of all the elements as an integer. Let the second parameter to the function be an integer which contains the number of elements of the array.
int total( int numbers[], int elements ) { int total = 0, loop; for( loop = 0; loop < elements; loop++ ) total = total + numbers[loop]; return total; }
int total( int numbers[], int elements ) { int total = 0, loop; for( loop = 0; loop <= elements; loop++ ) total = total + numbers[loop]; return total; }
int total( int numbers[], int elements ) { int total, loop; for( loop = 0; loop > elements; loop++ ) total = total + numbers[loop]; return total; }
6. A function prototype for the above function looks like
int total( char [] ); int total( int [], int ); void total( char [], int ); int total( void );
To submit your comments, press this button:
To clear the form, press this button:
©Copyright B Brown. 1984-1998. All rights reserved.