{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

H- Written QuestionsExam 2

# H- Written QuestionsExam 2 - Write a for loop that...

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

14:440:127, Fall 2008 Exam 2 Version H The entire exam is closed book, and there is no collaboration permitted. All of your answers must be written in blue books; you will have separate bluebooks for the “No Computer” and “Computer” sections. Be sure to put your name and RUID on all bluebooks you use. Each “Computer” question is worth twice as much as each “No Computer” questions. All answers must relate to the Matlab programming language. For the first 20 minutes, you will not be permitted to use the computer. After 20 minutes, we will collect your bluebook for the first 4 (written) questions, and you will be permitted no further changes to those answers. For the final 4 questions, you will be permitted to use the computer by logging in to your special “Exam Accounts.” If you log in to your normal engineering account at any point during the exam, you will automatically fail. “No Computer” Question 1:
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Write a for loop that calculates the sum of the prime numbers from 1 to 1000. Note: you cannot use the primes function, although you may certainly use isprime( ) . “No Computer” Question 2: Imagine that we had a new data type called int7 , storing 7 bit signed integers. What’s the largest integer that int7 could store correctly? “No Computer” Question 3: Write a function called hereyougo that returns a 1x2 vector of random integers between -20 and 43. “No Computer” Question 4: You are given the following two Matlab functions: Blase.m Tianming.m function y = Blase(x) function y = Tianming(x) global s; global s; s = 15; y = 22 + (s - x); y = x+s; Write down the output I’d get if I typed the following command into the workspace after saving those functions. If there is an error, instead explain why there’s an error, and how I could fix it. Z = Blase(3) + Tianming(2)...
View Full Document

{[ snackBarMessage ]}