{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Uitwerkingen_Februari_2012 - TU Delft Faculteit EWI...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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; }
Image of page 2
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)
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern