# quiz3 - returns the number of elements read this number is...

This preview shows page 1. Sign up to view the full content.

Programming Using C Quiz 3 Name: 1. [50 p ] Given the following code fragment: int i = 1, a[] = {0, 1, 2}, *b, *c; b = a; c = &i; decide whether the following C expressions are correct, and if they are, give their value. (a) [5 p ] a = b (b) [5 p ] a == b (c) [5 p ] b == a[0] (d) [5 p (e) [5 p ] b[0] == a[0] (f) [5 p ] c == b + 1 (g) [5 p ] *c == *(b + 1) (h) [5 p ] *(b + *c) == *(a + 1) (i) [5 p (j) [5 p 2. [50 p ] Write a program that ﬁnds the ﬁrst negative number in an array. The program should use the following functions: /* reads an array from keyboard and stores it in array a
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * returns the number of elements read; * this number is also read from the keyboard int read_array(int *a); /* finds the first negative number in array a. * If such number exists in a, the function returns 1 * and stores its value at address negative. * If such number does not exist, returns 0. */ int find_negative(int *a, int n, int *negative); You don’t need to write the read array function; just write the ﬁnd negative and main functions. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online