{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Uitwerkingen_Februari_2012

# Uitwerkingen_Februari_2012 - TU Delft Faculteit EWI...

This preview shows pages 1–5. Sign up to view the full content.

TU Delft Faculteit EWI Tentamen Programmeren in C (EE1400) 3 februari 2012, 9.00 – 12.00 Uitwerkingen Opgave 1 (24 punten) a. 6 11 b. 8 16 c. 12 3 d. 34 32 e. 17 76 f. n 1 Opgave 2 (8 punten) a. -9 b. 13 c. 81 d. 61

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Opgave 3 (10 punten) int sum, end, i; char s[128]; sum = 0; end = 0; scanf ("%s", s); i = 0; while (!end) { switch (s[i]) { case '1': sum += 1; break; case '2': sum += 2; break; default: end = 1; break; } i++; } printf ("sum=%d\n", sum); Opgave 4 (6 punten) De functie telt telkens een waarde 1 af van de beginwaarde, net zolang kleiner dan 1 is. Het aantal malen dat er afgetrokken, zo veel maal wordt er vermenigvuldigd met 2, waarbij de beginwaarde 4 is. int func (int x) { int a = 4; while (--x >= 1) { a = 2 * a; } return a; }
Opgave 5 (8 punten) Drie verschillende mogelijke oplossingen zijn: int str2int (char *s) { int i, v = 0, d = 1; for (i = strlen (s) - 1; i >= 0; i--) { v += d * (s[i] – '0'); d *= 10; } return v; } int str2int (char *s)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the 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