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 out the values 1 to 10 on separate lines, is
Statement 1
for( count = 1; count <= 10; count = count + 1) printf("%d\n", count);
Statement 2
for( count = 1; count < 10; count = count + 1) printf("%d\n", count);
Statement 3
for( count = 0; count <= 9; count = count + 1) printf("%d ", count);
Statement 4
for( count = 1; count <> 10; count = count + 1) printf("%d\n", count);
2. The statement which produces the following output is, (hint: use two nested for loops)
1 22 333 4444 55555
for(a = 1; a <= 5; a = a + 1) { for( b = 1; b <= 5; b = b + 1) printf("%d", b); printf("\n"); }
for( a = 1; a <= 5; a = a + 1) { for( b = 1; b <= a; b = b + 1) printf("%d", a); printf("\n"); }
for( a = 1; a <= 5; a = a + 1) { for( b = a; b <= 5; b = b + 1) printf("%d", b); printf("\n"); }
for( a = 1; a <= 5; a = a + 1) { for( b = 1; b < a; b = b + a) printf("%d", b); printf("\n"); }
3. The statement which sums all values between 10 and 100 into a variable called total is, assuming that total has NOT been initialized to zero.
for( a = 10; a <= 100; a = a + 1) total = total + a;
for( a = 10; a < 100; a = a + 1, total = 0) total = total + a;
for( a = 10; a <= 100, total = 0; a = a + 1) total = total + a;
for( a = 10, total = 0; a <= 100; a = a + 1) total = total + a;
4. The statement that prints out the character set from A-Z, is
for( a = 'A'; a < 'Z'; a = a + 1) printf("%c", a);
for( a = 'a'; a <= 'z'; a = a + 1) printf("%c", &a);
for( a = 'A'; a <= 'Z'; a = a + 1) printf("%c", a);
for( a = 'Z'; a <= 'A'; a = a + 1) printf("%c", a);
To submit your comments, press this button:
To clear the form, press this button:
©Copyright B Brown. 1984-1998. All rights reserved.