{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Test 2 Page 8

# Test 2 Page 8 - ’ following code is supposed to delete...

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: . ’ following code is supposed to delete all of the nodes from a linked list and free the 7 ory that they occupy. You may assume that ﬁrst points to the beginning of the linked list and that each node’s next pointer is in fact pointing to the next node, except for the last node whose next pointer is NULL. p is a legal pointer variable to a node. for (p = ﬁrst; p != NULL, p = p —> next) free (p); C. The following program is supposed to sum up the odd, positive integers in the range from 0 up to and including N (assume that N is odd). #include <stdio.h> r 0: _;_ #include <std11b.h> ~S {\$3096 int odd sum( int 19,—». { ifrn==0)e~ Mn: 0 "i loath)” / return 0; E— - rein/«n l' else 8 return odd_sum(n-2) + n; } . int main(void) i { int n; . printf("Enter a positive odd number: "); I scanf(" %d", &n); printf "odd sum %d: %d\n" , n, 0dd_surn(n)); return 0; } Page 9 Pager ...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern