ece190_sp11_exam1_prac_v1 - Spring 2011 Practice exam,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Spring 2011 Practice exam, February 2011 N a me : N et I D : Programming studio section (mark only the one you attend): 9:00 AM 12:00 PM 1:00 PM 2:00 PM 3:00 PM DCL 440 [ ] AD4 [ ] AD5 [ ] AD3 AD1 DCL 520 [ ] AD6 [ ] AD8 [ ] AD7 [ ] AD9 [ ] AD2 B e su r e you r e x a m b oo k l e t h as 5 p ages. D o not t e a r t h e e x a m b oo k l e t a p a r t . W r i t e y o u r n a m e a t t h e to p o f e a c h p a ge . T h is i s a c lose d b oo k e x a m . Y o u m a y n o t u se a c a l c u l a t o r . Y ou a r e a l l ow e d on e h a n d w r i t t e n 8.5 x 11 " sh e e t of n ot es. A b so l u t e l y n o i n t e r a c t i o n b e t w e e n s t u d e n t s i s a l l o w e d . B e su r e to c l e a r l y i n d i c a t e a n y assu m p t ions t h a t you m a k e . Problem 1 10 points _______________________________ Problem 2 5 points _______________________________ Problem 3 10 points _______________________________ Problem 4 5 points _______________________________ Total 30 points _______________________________ Name: ___________________________________________ Page: 2 P r ob l e m 1 (10 p oi n ts) : B i n a r y r e p r ese n t a t ion P a r t A (2 _____________________ _____________________ Unsigned binary: _____________________ P a r t B (2 through 7. Give the following equivalent numbers for octal number 1275 in each binary, decimal, and hexadecimal representation. Binary: _____________________ Decimal: _____________________ Hexadecimal: _____________________ P a r t C (1 point): How is the number represented in the floating point data type format? Answer: _________________________________________________ P a r t D (1 points): What is the largest possible positive number that can be expressed in the floating point data type, using an exponent between 1 and 254? Write your answer in binary, in IEEE 754 floating point format. Answer: _________________________________________________ P a r t E (4 points): Using 2-complement arithmetic, what 32-bit number can be added to this floating point number to effectively multiply by 28? 0 01111101 00000000000000000000000 Answer: _________________________________________________ Page: 3 Name: ___________________________________________ AND OR Answer: ____________________________ Page: 4 Name: ___________________________________________ P r ob l e m 3 (10 p oi n ts) : M e mo r y Given four 1-bit memory cells, build a 2x2-bit memory unit using only AND, OR, NOT gates and MUXes: Page: 5 Name: ___________________________________________ if(_________________________________________)  f=x  elseif(____________________________________)  f= x  else  f=x+1  intx=5  do{    x)  }while(x!=4)  printf intcount  charinchar  printf d ___________________)  Page: 6 Name: ___________________________________________ h, each dart will have an x coordinate and a y coordinate of the point where it lands. You will then calculate what fraction of darts falls within a circle with center (0,0) and radius 1. Remember that the point (x,y) is distance from the origin (0,0). If you throw 100+ darts in this manner, the fraction of darts hitting the unit circle Your program will first request how many darts you will throw. It will then loop through each dart, prompting "x and y for dart i? " where i is the number of the current dart, starting from 0. Finally, your program should output "You hit the unit circle j times." followed by a newline, where j is the number of darts that landed in the circle. Here is a sample run: Howmanydarts?10 xandyfordart0? 0.233169 0.866316 xandyfordart1? 0.999984 0.736924 xandyfordart2?0.511211 0.082700 xandyfordart3?0.065534 0.562082 xandyfordart4? 0.9059110.357729 xandyfordart5?0.3585930.869386 xandyfordart6? 0.2329960.038833 xandyfordart7?0.661931 0.930856 xandyfordart8? 0.8930770.059400 xandyfordart9?0.342299 0.984604 Youhittheunitcircle7times You may NOT use any functions from math.h, such as sqrt. NOTE: For testing purposes, you can generate x and y coordinates on the interval [-1, 1] by writing at the top of your program #include<stdlib.h> #defineFRAND(rand()/(RAND_MAX/2.0) 1.0) and using "x=FRAND " to obtain a new random number to assign to x instead of using scanf to obtain this value form user. Do not forget to remove this test code when turning in your final program! exam1.c gcc g Wall Werror ansiexam1.c otest handin  EX1exam1.c ...
View Full 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.

Ask a homework question - tutors are online