THIS IS QUIZ #3


Bug Hunt

Question 1: Submit your answer as quiz3_1.txt

20 pts.

List all errors and Identify them.
There can be ZERO or MORE Errors per line.


NOTE:
the "(" and ")" around the header file is not an error --
this is just an HTML problem.  Pretend they are the angled brackets.



1	#include (stdio.h)
2	/* program with errors /*
3
4	#define X = 3
5
6	main( void ) {
7		int z = 12;
8		int X = 5;
9		if X < z        */ two printfs if X < z
10			printf("z is %d and is");
11			printf(" larger than X\N", z);
12
13		return 0;
14	}


Question 2: Submit your answer as quiz3_2.txt

20 pts.

True/False -- Short Answer

List the numbers of the true statements.

In the questions below:
The Variables: a, b, c are floats, x, y, z, r are ints
With values: a = 2.3, b = 3.3, c = 4.0, x = 3, y = 5, z = 4



1. T/F:  High-level programming languages are not machine independent.
2. T/F:  In this statement, the value of r is True.
               r = ((a >= b) && ( c > y / (x++ -z) ));
3. T/F:  The do-while loop is the only one that executes before
             testing the condition.
4. T/F:  The three levels of computer languages are machine language,
	     C, and C++.
5. T/F:  Elements in an array are the same in type and the amount
	     memory required.



Question 3: Submit your answer as quiz3_3.txt

10 pts.

What does this program do -- WHAT IS IT'S OUTPUT ?

NOTE: the “(” and “)” around the header file is not an error -- this is just an HTML problem. Pretend they are the angled brackets.

	#include (stdio.h)
	main()
	{
		int i, j, sum;
		for( i = 1; i<=10; i++ ){
			for( j = i; j>0; j-- )
				printf("-");
			printf("%d", i);
			if( i % 3 == 0 )
				printf("\n");
		}
		printf("\n");
		return 0;
	}


PROGRAMMING TIME!

Question 4: Submit your answer as quiz3_4.txt

40 pts.

Write a program that has two arrays:
	int arr1[10];
	int arr2[10];
And whatever other variables you choose.


And does the following:

	1) Reads in the values for the 10 elements of arr1.

	2) Your program should assign to each element i of arr2
	   the sum of the elements 0 through i of arr1.

	3) Print all elements in both arrays.



For Example:  If arr1's elements are:

   _________________________________________
  |   |   |   |    |   |   |   |   |   |    |
  | 3 | 1 | 4 | 10 | 0 | 2 | 2 | 5 | 1 | 11 |
  |___|___|___|____|___|___|___|___|___|____|

    0   1   2   3    4   5   6   7   8    9


Then arr2's Elements will be:
   ______________________________________________
  |   |   |   |    |    |    |    |    |    |    |
  | 3 | 4 | 8 | 18 | 18 | 20 | 22 | 27 | 28 | 39 |
  |___|___|___|____|____|____|____|____|____|____|

    0   1   2   3    4    5    6    7    8    9



Notice, One way to look at it is:
	arr2[0] = arr1[0];
	arr2[1] = arr1[0] + arr1[1];
	arr3[2] = arr1[0] + arr1[1] = arr2[2];
	etc.



More Bugs

Question 5: Submit your answer as quiz3_5.txt

10 pts. All or Nothing

This program should clear an array and return. List the line numbers of all lines with bugs/problems in them and tell what the errors are. --- If Any.

LINE NUMBER:           CODE:
--------------|------------------------------------------
   1          |    int main (void)
   2          |       {
   3          |       int i;
   4          |       int a[10];
   5          |
   6          |       for( i = 0; i <= 10; i++ )
   7          |           a[i] = 0;
   8          |       return 0;
   9          |       }


Back to the Top of this page


[Back to the Index]

graphics images Copyright 1998-2003 Elizabeth Fraley HTML code copyright 1998-2003 Elizabeth Fraley. Permission is given to provide these pages in their original, unaltered form online for educational purposes. They may not be republished or included on a CDROM, disk or other media or with any published work without the express permission of the copyright holder (this includes FAQ books).