lab arrays debugging

2
 ICOM 4035 Laboratory Laboratory 5: Arrays & Debugging Exercise 1: Duplicate Elimination A. Given an array of size 5, read user input into the array. Each time a value is inserted into the array, the array elements are printed. If the user attempts to input a value that already exists in the array, the program will print the given value with a message to the effect that the value already exists. Code: lab_duplicate Example: Array Size: 5 Enter number: 1 1 Enter number: 2 1 2 Enter number: 1 1 2 1 has already been entered Enter number 3: 1 2 3 Enter number: 4 1 2 3 4 B. Modify the code from item A in order for the array to hold 30 numbers, which will be between 20 and 600, inclusive. C. Modify the code from item B to allow the user to enter numbers until the array is full. D. Modify the code from item C to allow the user to set the array size. Exercise 2: Fix all the compilation errors, so that the program will compile successfully. Once the program compiles, compare the output to the sample output, and eliminate any logic errors that exist. The sample output demonstrates what the program’s output should be once the program’s code is corrected. Code: lab_debugging Example: See debugging_sampleOutput.txt

Upload: christopher-torres-lugo

Post on 04-Oct-2015

2 views

Category:

Documents


0 download

DESCRIPTION

ICOM 4035 Laboratory

TRANSCRIPT

  • ICOM 4035 LaboratoryLaboratory 5: Arrays & Debugging

    Exercise 1: Duplicate Elimination

    A. Given an array of size 5, read user input into the array. Each time a value is inserted into the array, the array elements are printed. If the user attempts to input a value that already exists in the array, the program will print the given value with a message to the effect that the value already exists.

    Code: lab_duplicateExample:

    Array Size: 5

    Enter number: 11Enter number: 21 2Enter number: 11 21 has already been enteredEnter number 3:1 2 3Enter number: 41 2 3 4

    B. Modify the code from item A in order for the array to hold 30 numbers, which will be between 20 and 600, inclusive.

    C. Modify the code from item B to allow the user to enter numbers until the array is full.

    D. Modify the code from item C to allow the user to set the array size.

    Exercise 2:

    Fix all the compilation errors, so that the program will compile successfully. Once the program compiles, compare the output to the sample output, and eliminate any logic errors that exist. The sample output demonstrates what the programs output should be once the programs code is corrected.

    Code: lab_debugging

    Example: See debugging_sampleOutput.txt