# e2.f08 - ECE190 Exam 2 Fall 2008 Thursday 30 October Name...

This preview shows pages 1–5. Sign up to view the full content.

ECE190 Exam 2, Fall 2008 Thursday 30 October Name: Be sure that your exam booklet has 13 pages. The exam is meant to be taken apart! Write your name at the top of each page. This is a closed book exam. You may not use a calculator. You are allowed TWO 8 . 5 × 11 " sheets of handwritten notes. Absolutely no interaction between students is allowed. Challenging problems are marked with ***. Show all of your work. Don’t panic, and good luck! “...if rationality were the criterion for things being allowed to exist, the world would be one gigantic Feld of soya beans!” —from the play Jumpers by Tom Stoppard Problem 1 20 points Problem 2 15 points Problem 3 25 points Problem 4 20 points Problem 5 20 points Total 100 points

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Name: ____________________________________________ 2 Problem 1 (20 points): Short Answers Please answer concisely. If your answer requires more than a few words or a simple figure, it is probably wrong. Part A (5 points): Consider the following C function. int mystery () { int x = 1; int y = 10; do { y = y + x; if (4 < x) { break; } x = x * 2; } while (20 > y); printf ("%d\n", y); /* A(i) refers to this line. */ return x; /* A(ii) refers to this line. */ } i) What number does the call to printf in the mystery function output to the display? ii) What value does the mystery function return? Part B (5 points): Consider the C code snippet below. int a = 10; int b = 5; int c = 10; c = (a++) + (--b) + c; Write the values of the three variables after all of the assignments have completed. a ___________ b ___________ c ___________
Name: ____________________________________________ 3 Part C (5 points): Consider the following C program. #include <stdio.h> int glob = 42; void fn (); int main () { double mine = 3.8; printf ("glob=%d\n", glob); fn (); return 0; } void fn () { glob = mine; printf ("glob=%d\n", glob); } The code contains a single error. Explain the error. Part D (5 points): Most functions require a specific number of arguments. A few, such as scanf , take a variable number of arguments. In the C declaration below, the ellipsis (±²³) following the first argument indicates that a variable number of additional arguments can be passed. void variable_args (int num_args, . ..); For the variable_args function, the num_args argument indicates the number of additional arguments. For example, the call variable_args (2, 4, 5) indicates that two additional arguments (4 and 5) are being passed. When a compiler generates assembly code for a call to the variable_args function, should the num_args argument be pushed first or last (or does it not matter, if all compilers are required make the same choice)? Explain your answer.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Name: ____________________________________________ 4 Problem 2 (15 points): Assemblers and Assembly Language This exam you are now taking was written by a program outputting the text to the console and redirecting that to a text file (think of comparisons you made for MP2). The first function we wrote was
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/23/2012 for the course ECE 190 taught by Professor Hutchinson during the Spring '08 term at University of Illinois, Urbana Champaign.

### Page1 / 13

e2.f08 - ECE190 Exam 2 Fall 2008 Thursday 30 October Name...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online