CSE 130 Spring 2010 Lab 6 PLEASE DO NOT SUBMIT LAB EXERCISES. They are for your practice only. 1. Two parts of Lab 4 - There are two parts to this exercise. In the first part we cal- culate mean of values stored in one dimensional array. For the second part, we print values of a two dimensional array using nested for loops. - Copy lab6.c from this page. Just cut and paste it in your pico window. // lab6.c // CSE 130 Spring 2010. Lab 6, March 10, 2010 // Sample program for studying arrays. #include int main (void) { float sum, average; int i; // Declare Array A. // Initialize array A. // Calculate sum and average. // Print sum and average. return 0; } 2. Actual program. a. First declare an array A of type float and size 6. For example, float A[6]; b Initialize this array by using A[i] = 10.0 + (float)i; inside a for loop that runs from i = 0 to 5. c. Print array A, from left to right, so you verify what values are in A. Use a for loop and a printf statement inside the loop. for (i=0; i < 6; i++) { printf(" %f ", A[i]); } Values are 10.0 11.0 12.0 13.0 14.0 15.0 d. Write another for loop to obtain sum of all elements of array A in a variable sum (type float). sum[i] = sum + A[i]; Do not forget to initialize sum before the loop. Calculate aver- age = sum/6.0; e. Print sum and average using a printf statement. f. Save your program as lab6.c, compile and execute. g. Average printed should be 12.5. 3. Part-2 h. Copy your program lab6.c to lab62.c. [ cp lab6.c lab62.c ] Here square brackets are not included. 2 means the second version of lab6. i. Modify lab62.c as follows. Make array A two dimensional. A[6][4]. So it will have 6 rows and 4 columns. Delete all lines that compute and print sum as well as average. j. Declare j to be an integer. Initialize this array using values based on indices i, j. Try A[i][j] = float(i*i + j)/2.0. Write this as two nested for loops. TA will tell you how to do this. k. Now print array A using another pair of nested loops. Do not forget to print \n in the outer loop. Get help from TA. l. Save your program lab62.c, compile and execute. m. For the 0th row of A, i = 0 and j varies from 0 to 3. So the first row should be 0.0 0.5 1.0 1.5 There will be 5 more rows. Verify that it does print these rows with correct values as shown. 0.0000 0.5000 1.0000 1.5000 0.5000 1.0000 1.5000 2.0000 2.0000 2.5000 3.0000 3.5000 4.5000 5.0000 5.5000 6.0000 8.0000 8.5000 9.0000 9.5000 12.5000 13.0000 13.5000 14.0000 n. Extra: Write code for adding all 24 values in the array. Print the total. It should be 128.0. Verify if your program prints that.