Lecture20-Homework-pointers.pdf - COMP.1010 Homework Pointer F19 Dr Lin Due date Oct 25 2019(F BEFORE the class starts Name Section_10am_11am You must

Lecture20-Homework-pointers.pdf - COMP.1010 Homework...

This preview shows page 1 - 2 out of 2 pages.

COMP.1010 Homework, Pointer, 10-21-2019 F19 - Dr. Lin Due date : Oct. 25, 2019 (F), BEFORE the class starts Name : _______________________________________ Section: ______10am_________11am_________ You must Run the following C code and get the run-time values from your computer memory to answer questions 2~4. You may type the code in zyBook section 9.4; add printf with %p if needed to observe the values. #include <stdio.h> int main( int argc, char * argv[]) { int *p1, *p2, *p, a, b; printf ( "Please enter two integers: " ); scanf ( "%d,%d" , &a, &b); //enter two integers //separated by a comma ‘,’ p1 = &a; p2 = &b; if (a < b) { p = p1; p1 = p2; p2 = p; } printf ( "a=%d, b=%d\n" , a, b); printf ( "max=%d, min=%d\n" , *p1, *p2); return 0 ; } 1. What is a pointer in C? Which variables in this program are pointer variables? 2. What are the values of expression p1, p2, &a, and &b in your computer before the
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

Unformatted text preview: if statement executes? (Add printf or use breakpoints to check the run-time variable values) p1 _________________________ p2 _________________________ &amp;a _________________________ &amp;b _________________________ COMP.1010 Homework, Pointer, 10-21-2019 F19 - Dr. Lin 3. What are the values of p1, p2, p in your computer after if statement executes and before the printf statements execute? (You may add printf or use breakpoints to check the values) p1 _________________________ p2 _________________________ p ___________________________ 4. What does this program do? Draw graph(s) (the ones we use in class) to support your description. 5. Were the values of a and b changed in program execution? What are changed? 6. What is the purpose to use the pointer p?...
View Full Document

  • Fall '15

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors