Preview

guide to tut

Better Essays
Open Document
Open Document
832 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
guide to tut
Tutorial 10a

Array

QUESTIONS
1. For the declaration char grades [5] ;
How many memory cells are allocated for data storage? What types of data can be stored there? How does one refer to the initial array element? To the final array element?
2. For the following array, describe what happens when the following statements are executed for i = 3 ;

Array x
0.0

1.0

2.0

8.0

12.0

5.0

14.0

7.0

i = 3; printf (“%d %.1f” , 4, x[4]) ; printf (“%d %.1f” , i, x[i] ) ; printf (“%.1f”, x[i] + 1) ; printf (“%.1f”, x[i] + i) ; printf (“%.1f”, x[i + 1]) ; printf (“%.1f”, x[i + i]) ; printf (“%.1f”, x[2 * i] ) ; printf (“%.1f”, x[2 * i – 3]) ; printf (“%.1f”, x[ (int)x[4] ]) ; printf (“%.1f”, x[i ++]) ; printf (“%.1f”, x[--i]) ; x[i – 1] = x[i] ; x[i] = x[i +1] ; x[i] - 1 = x[1] ;

3. Is the following legal? int x[5] = {1, 2, 3, 4, 5} ; int y[5] ; y = x;
4. Write prototype for the following. Do not write the functions.
i) A function called largest that gets an array of integers and returns an integer. ii) A function called price that gets two double array names for input and a double array name for output. The function does not return a value.

5. Combine the following two statements into one statement. db1_arr[i] = data ;
++ i ;
6. We can represent a real polynomial p(x) of degree 3 using an array of the real coefficients a0, a1, a2 and a3. p(x) = a0x3 + a1x2 + a2x + a3
Write a function get_poly that inputs a polynomial of degree 3. It fills the double array of coefficients, coeff [ ], with inputs from the user. Also write a function poly that evaluates the polynomial at a given value of x. Use the following prototypes. void get_poly (double coeff [ ]) ; double poly (double x, double coeff [ ]) ;
The above two function can be used in the question to estimate the roots of a cubic polynomial in Tutorial 9.
HANDS-ON EXERCISES
7. Write a program to sum an array of integers called number which has 12 elements.

You May Also Find These Documents Helpful