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 statement which prints the integer values 1 to 10 on the screen, is
12345678910
Statement 1
count = 1; while( count <= 10 ) { printf("%d", count); count = count + 1; }
Statement 2
count = 1; while( count <= 10 ) { printf("%d", &count); count = count + 1; }
Statement 3
count = 1; while( count < 10 ) { printf("%d\n", count); count = count + 1; }
Statement 4
count = 1; while( count <= 10 ) { printf("%d\n", count); count = count + 1; }
2. The statement which reproduces the following output, is
1 22 333 4444 55555
a = 1; while( a <= 5 ) { while( b <= a ) { printf("%d\n", a); b = b + 1; } a = a + 1; }
a = 1; while( a <= 5 ) { b = 1; while( b <= a ) { printf("%d", a); b = b + 1; } printf("\n"); a = a + 1; }
a = 1; while( a <= 5 ) { while( b <= 5 ) { printf("%d", a); b = b + 1; } a = a + 1; printf("\n"); }
a = 1; while( a <= 5 ) { printf("\n"); b = 1; while( a <= b ) { printf("%d", a); b = b + 1; } a = a + 1; }
3. The statement that compares the value of an integer called sum against the value 65, and if it is less, prints the text string "Sorry, try again", is
if( sum < "65" ) printf("Sorry, try again" );
if( sum <= 65 ) printf("Sorry, try again" );
if( 65 == sum ) printf("Sorry, try again" );
if( sum < 65 ) printf("Sorry, try again" );
4. The statement that compares total for equality to good_guess, and if equal prints the value of total, and if not equal prints the value of good_guess, is
if( total < good_guess ) printf("%d", total ); else printf("%d", good_guess );
if( total == good_guess ) printf("%d", good_guess ); else printf("%d", total );
if( total = good_guess ) printf("%d", total ); else printf("%d", good_guess );
if( total == good_guess ) printf("%d", total ); else printf("%d", good_guess );
To submit your comments, press this button:
To clear the form, press this button:
©Copyright B Brown. 1984-1998. All rights reserved.