2019.11.07_revised.pdf - Quiz ‣ Please complete today's poll 1 Quote of the Day ‣"If debugging is the process of removing bugs then programming must

2019.11.07_revised.pdf - Quiz ‣ Please complete today's...

This preview shows page 1 - 15 out of 63 pages.

Quiz Please complete today's poll 1
Image of page 1
Quote of the Day 2 "If debugging is the process of removing bugs, then programming must be the process of putting them in." •Edsger W. Dijkstra Eagleson's Law of Programming: Any code of your own that you haven't looked at for six or more months might as well have been written by someone else.
Image of page 2
Announcements pick up midterm exams •this week no labs next week Tuesday and Thursday helpdesk •Tuesdays, 13:00-14:00 (1 p.m. - 2 p.m.), Rm S311 •Thursday, 16:00-17:00 (4 p.m. - 5 p.m.), Rm S320 3
Image of page 3
Results from Poll 4
Image of page 4
Addressing 5 most relevant portions of code can we say instead? double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c);
Image of page 5
Addressing 6 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); associates as x = (v2[r])[c];
Image of page 6
Addressing 7 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); type: double *
Image of page 7
Addressing 8 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); type: double * pointer to start of one of these vectors
Image of page 8
Addressing 9 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); type: double * pointer to start of one of these vectors which element in one of those vectors? c -th associates as x = (v2[r])[c];
Image of page 9
Addressing 10 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); type: double * pointer arithmetic scaled by sizeof(double)
Image of page 10
Addressing 11 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); evaluates to address of element c (starting at 0) in vector pointed to by v2[r] (i.e. row r in v2 , starting at 0)
Image of page 11
Addressing 12 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); dereferencing the address gives us the value of element c (starting at 0) in vector pointed to by v2[r] (i.e. row r in v2 , starting at 0)
Image of page 12
Addressing 13 most relevant portions of code can we say double x, *v2[3]; v2[0] = calloc( 5, sizeof( double ) ); v2[1] = calloc( 5, sizeof( double ) ); v2[2] = calloc( 5, sizeof( double ) ); x = v2[r][c]; x = *(v2[r]+c); dereferencing the address gives us the value of element c (starting at 0) in vector pointed to by v2[r] (i.e. row r in v2 , starting at 0)
Image of page 13
Addressing 14 most relevant portions of code can we say instead?
Image of page 14
Image of page 15

You've reached the end of your free preview.

Want to read all 63 pages?

  • Spring '14

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

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes