Sie sind auf Seite 1von 4

Topic 2:

Single Dimensional and Multidimensional Arrays


Objectives At the end of the lab session, students should be able to: Use single-dimensional arrays for representing collection of data. Use single-dimensional arrays for representing polynomials. Use multi-dimensional arrays for representing matrices. Manipulate data in single-dimensional arrays for computing mean, standard deviation, summation, and other statistical algorihtms. Manipulate data in single-dimensional arrays to represent and evaluate polynomials. Manipulate data in multi-dimensional arrays for basic matrix operations (addition, multiplication, and transpose).

Preliminary Report to be extracted 10 minutes after the start of the class. Final Program to be extracted 10 minutes before the end of the class.
Preliminary Report Requirements
Introduction (10%, should provide a clear introduction to the concept behind the laboratory exercise. Significance of concept was properly emphasized.) Provide a brief background about arrays and its importance to C programming and engineering applications. Concept Theory (30%, required concepts are clearly discussed; discussed concepts are correct) Concept Examples (20%, Group members provided their own examples and/or code snippets based on their understanding of the concept.) Arrays Research about single-dimensional arrays and multi-dimensional arrays in C programming. Include the following concepts in your discussions: array declaration (for all basic data types), array size, index, lower-bound, and upper-bound. Show example code snippets.

Polynomials Review your concept of polynomials. Study basic polynomial arithmetic and evaluation.

Arrays are used in the final program to represent polynomials. For example, a third-order polynomial requires a double array with size of three, such that it is declared: double poly[3]; Constants of polynomials are assigned to elements of the array. For example. poly[0] is the constant for x^0, poly[1] is the constant for x[1], etc. Statistical Algorithms Review your basic statistical algorithms for finding the mean, standard deviation, and summation of a collection of data. You will be using an array to store data for these statistical operations. Arrays are used to represent collection of data for statistical algorithms. A collection of data with 10 elements would require a double array with 10 elements: double data[10]; Matrix Operations Review your matrix operations (addition, multiplication, and transpose). A multi-dimensional array is used to represent a matrix. For example, a 3x1 matrix would require an array declaration of: double matrix[3][1]; Likewise, a 1x3 matrix would require an array declaration of : double matrix[1][3]; Rows and columns can be interchanged in the multi-dimensional array declaration. Make sure you are consistent with the declaration such that if the first index is declared as rows and second index is declared as columns, the entire program should make use of the first index as row and second index as column. Algorithms, Flowcharts and/or Pseudo-codes (20%, Design meets the final program requirements; flowcharts and/or seudo-codes are correct and implementable. ) Algorithms of operations should be presented in detail including per element manipulation of array elements. Test data (10%, proposed test data are valid and can thoroughly check the validity of the final program) Teachers Evaluation (10%, group members are knowledgeable of the topic; sources and references are properly cited; written reports presented well)

Final Program Requirements


Program shows a menu selection screen that allows the user to select between polynomial evaluation, statistical algorithms, and matrix operations. For polynomial evaluation: Program asks for the order of the polynomial (max. 10). Program asks for the constants of the polynomial. Program asks for the value of the variable and evaluates the polynomial. Program should ask if the user wants to repeat computation, else, program returns to the selection screen. For statistical algorithms: Program asks for the number of data (max 10). Program asks for the actual values of data. Program allows the user to select a statistical algorithm: mean, standard deviation, or summation of data. This screen also allows the user to go back to the menu selection screen. Program computes formula selected by user and goes back to the statistical algorithm selection screen. For matrix operations: Program manipulates two MxN matrices (max of 3x3, can be 2x1, 1x3, etc.). Program shows a matrix operation selection screen that allows the user to select between entering the values of the first matrix, the second matrix, or to do matrix operations of addition, multiplication, or transpose. This screen should also allow the user to go back to the menu selection screen. Program computes for the operation selected by user and goes back to the matrix operation selection screen.

Test Walkthrough 1. Select polynomial evaluation. 2. Enter a test polynomial. Repeat until two polynomials are tested. 3. Select statistical algorithms. 4. Enter a set of test data. Compute for mean, standard deviation, and summation. Repeat for two sets of test data. 5. Enter an invalid choice at the statistical algorithm selection screen. 6. Select matrix operations. 7. Enter values for first matrix and second matrix. 8. Do matrix operations. 9. Repeat step 7 and 8 by entering a 3x3 matrix for the first matrix with the second matrix being a 3x3 identity matrix. 10. Enter an invalid choice at the matrix operation selection screen. 11. Enter an invalid choice at the menu selection screen. 12. Quit the program.

Final Program Evaluation Criteria


Program Execution (40%) Final program requirements are met. -5 is given for each final program requirement not met, for a maximum of -40. Adherence to Design (20%) Implementation is faithful to the design. Implementation did not deviate from the flowchart or pseudo-code algorithms. Robustness (10%) Implementation is free from semantic errors, e.g. logical errors, runtime errors, etc. -2 deduction is given for each error encountered, to a maximum of -10. Code Formatting (10%) Proper indents used for conditional and iterative statement blocks. Proper literal names were used. In-line comments (where appropriate) were used. Code Efficiency and Modularization (10%) Loops are efficient. Functions are modular. Program did not make use of unnecessary variables Teacher's Evaluation (10%) Group members are all knowledgeable of the program. Program outputs are properly organized. Graphics were used to demonstrate functionalities, when needed. Program is user friendly. The lab instructor can easily navigate and use the program. Program explains what it can do.

Das könnte Ihnen auch gefallen