×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

## CSE 340 - Test 2 Prep

by: Dan Notetaker

87

1

4

# CSE 340 - Test 2 Prep

Marketplace > Arizona State University > > CSE 340 Test 2 Prep
Dan Notetaker
ASU

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

Test prep
COURSE
PROF.
TYPE
Test Prep (MCAT, SAT...)
PAGES
4
WORDS
CONCEPTS
Computer Science, programming, program, CSE340, cse, ASU, 340, Bazzi
KARMA
75 ?

## Popular in Department

This 4 page Test Prep (MCAT, SAT...) was uploaded by Dan Notetaker on Sunday February 21, 2016. The Test Prep (MCAT, SAT...) belongs to at Arizona State University taught by in Summer 2015. Since its upload, it has received 87 views.

×

## Reviews for CSE 340 - Test 2 Prep

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/21/16
Arizona State University Computer Science and Engineering CSE 340 - Fall 2013 Test 2. October 10 NAME: Read everything carefully. Some statements can be tricky. Consider the following program written in C syntax: int a, b, c; int h(int); int f(int a) { b = h(b)+c; printf("%d %d %d", a, b, c); // point 1 return b; } int g(int b) { printf("%d %d %d", a, b, c); // point 2 return h(b); } int h(int c) { a = a+1; b = b+1; printf("%d %d %d", a, b, c); // point 3 return a+b+c; // point 4 } main() { int b; a = 1; b = 2; c = 3; a = f(a); printf("%d %d %d\n", a,b,c); // point 5 } Assume lexical scoping is used and parameters are passed by value. Pass- ing a parameter by value means that the value of the parameter (actual param- eter) should be evaluated before the call and copied to the location associate with the local variable of the function (the formal parameter). Assume that variables that are not explicitly initialized by the program have initial value 0. For each of the following sentences ▯ll in the blank in the sentence. 1. At point 1, the parent scope of f() is . 2. T F At point 1, the global names are not visible. 1 3. The values printed just before point 1 are . 4. The values printed just before point 2 are . 5. The values printed just before point 3, ▯rst call, are . 6. The values printed just before point 4, ▯rst call, are . 7. The values printed just before point 3, second call, are . 8. The values printed just before point 4, second call, are . 9. The values printed just before point 5 are . Assuming dynamic scoping is used and parameters are passed by value, indi- cate for each of the following sentences if it is true or false by circling the T or F next to the sentence. If there is no T or F next to the sentence, then ▯ll in the blank in the sentence. 10. At point 1, the parent scope of f() is . 11. T F At point 1, the global name a is not visible. 12. T F At point 1, the global name b is not visible. 13. The value of printed just before point 2 is . 14. The value of printed just before point 3 is . 15. The value of printed just before point 4 is . 16. The value of printed just before point 5 is . 17. The value of printed just before point 6 is . 18. The value of printed just before point 7 is . 2 Consider the following code written in C syntax. Assume assignment has copy semantics and stack memory allocation for nested scopes is imple- mented. Float variables are stored in 8 bytes and integer values are stored in 4 bytes with the most signi▯cant bit as the sign bit (0 positive and 1 nega- tive) and the remaining bits representing the magnitude. The ▯rst 4 bytes of a oat variable are the integer part and the second 4 bytes are the decimal part. Assume the stack starts at location 1024. Assume the variables are allocated locations in the order they are declared. So, in the code below, the ▯rst a will be at address 1024 and the ▯rst b will be at address 1028. Assume pointer variables are stored as unsigned integers in 4 bytes and are initially NULL (0). Non-pointer variables are not initialized. For each of the following, ▯ll in the blank. For sentences about values, write \unknown" If a value is unknown. For questions that ask for aliases, do not answer with trivial aliases. { int a, b; int **p1; int **p2; a = 1; b = 2; { int a; { int *c[4]; c[0] = (int *) malloc(sizeof(int)); // point 0 c[1] = (int *) malloc(sizeof(int)); // point 1 c[2] = &a; // point 2 c[3] = &c[0]; // point 3 p1 = &c[2] // point 4 p2 = p1; // point 5 } // point 6 { int a; // point 7 float f; // point 8 } } } 19. The value of c[2] at point 2 is . 20. The value of c[3] at point 3 is . 21. The address of a at point 2 is . 22. The address of c[3] at point 2 is . 23. The address of a at point 6 is . 24. The address of a at point 7 is . 3 25. The value of p1 at point 4 is . 26. At point 4, *p1 is an alias of . 27. At point 5, **p2 is an alias of . 28. The dangling reference(s) at point 6 is (are) . 29. The memory allocated at point 0 is garbage at points: . 30. The memory allocated at point 1 is garbage at points: . 31. The value of a at point 7 is . 32. The value of f at point 8 is . 4

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Jennifer McGill UCSF Med School

#### "Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over \$500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com