ECE 220
Midterm (A)
March 12th, 2025, 1:00PM
Name:
Student ID:
Signature:
Instructions
• PRINT YOUR NAME and Student ID into the boxes above.
• Sign in the Signature box.
• Write your name and your Student ID on the General Purpose Answer Sheet. Your
Student ID should be left-aligned, e.g.
• Fill in the bubbles on the General Purpose Answer Sheet to code in your name and ID.
• Write 100000 in Special Code on the General Purpose Answer Sheet.
• This is a CLOSED BOOK exam. Time allowed: 50 minutes.
• Calculators, cell phones, or computers of any kind are not permitted.
• This exam, worth 90 points, counts 15% toward your final grade in this course.
• Write your answers properly on the answer sheet with an HB pencil. If the optical reader
cannot clearly read your answer, the mark on that question will be 0.
• All the C code provided in this exam is ANSI standard and uses the ASCII character set.
• For questions regarding code fragments, assume that all the necessary header files
and surrounding code are provided.
• Questions are weighted differently in each part: Points
o Part 1 - (5 questions at 3 point each) 15
o Part 2 - (5 questions at 5 points each) 25
o Part 3 - (5 questions at 6 points each) 30
o Part 4 - (2 questions at 10 points each) 20
• This question booklet must be returned with your General Purpose Answer Sheet for
you to get credit for this exam.
• IMPORTANT: Answer Parts 1, 2 and 3 in the General Purpose Answer Sheet. For
Part 4 use the space provided in this booklet.
page 1 of 12
, ECE220 – Programming for Electrical Engineering
Part 1: [15 points total – 5 Questions – 3 points each] – Multiple Choice Questions
Answer the following questions starting at question number 1 on the front of your General
Purpose Answer Sheet]
1. What is the output produced by the following code?
int x = 5, y = 10;
int *p1, *p2;
p1 = &x;
p2 = &y;
*p1 = *p2 + 2;
printf("%d %d\n", x, y);
a) 5 10
b) 12 10
c) 10 12
d) 7 10
e) 5 12
2. What is wrong with the following code?
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
ptr = ptr + 2;
arr = ptr;
a) You cannot modify (reassign) array names
b) Array index out of bounds
c) Incorrect pointer arithmetic
d) Incorrect array initialization
e) No error, the code is fine
page 2 of 12