100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Programming Language Concepts CMPSC 461, FALL 2018 Midterm #2 Solutions

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
25-09-2023
Written in
2023/2024

Programming Language Concepts CMPSC 461, FALL 2018 Midterm #2 Solution P# Possible Score 1 8 2 10 3 16 4 8 5 24 6 16 7 10 8 8 Bonus 10 Total 110 This exam is closed book, closed notes. You may not use any additional materials during the exam. All electronic devices must be put away. You may have nothing on your desk except this exam and writing instruments. The exam consists of 8 questions and 1 bonus question on 5 pages, totaling 100 points + 10 bonus points. Read each question carefully and use your time judiciously. The problems are not ordered by their difficulty. Problem 1 [8pt] For each of the following Scheme programs, circle all x’s that refer to (i.e., are in the scope of) the definition of x at the SECOND LINE. You don’t need to circle anything if no such x exists. Solution: (let ((x 1)) (let ((x 2) (y x)) (+ x y)) (let ((x 3)) (let* ((x 4) (y x )) (+ x y))) Problem 2 [10pt] Consider the following C++ program: int *a, *b; void f() { int c=5; a = new int(3); b = &c; } void g () { } int main() { f(); printf("%d,%d,", *a, *b); g(); printf("%d,%dn", *a, *b); delete a; } 1. (4pt) What is the storage allocation (static/stack/heap) for the integers that a and b points to in function f (before f returns)? Solution: Variable a points to a heap allocated integer variable b points to a stack allocated integer 2. (6pt) Here are the outputs of two separate executions of the program: (first run) 3, 5, 3, 32537 (second run) 3, 5,

Show more Read less









Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
September 25, 2023
Number of pages
6
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsConnoisseur Self
View profile
Follow You need to be logged in order to follow users or courses
Sold
566
Member since
2 year
Number of followers
343
Documents
1497
Last sold
1 week ago

4.3

67 reviews

5
40
4
11
3
12
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions