Download presentation
Presentation is loading. Please wait.
Published byLawrence Jennings Modified over 9 years ago
1
1
2
Exam Topics Difference between computers and calculators John creates a new device. It will compute the orbit of all the planets in the solar system simultaneously. Since it won’t do anything else, he hopes to one day make another machine that will compute the orbit of the stars in the Milky Way. Is John’s current device a computer? a calculator? 2
3
Exam Topics Software, Hardware, and Media Provide a simple definition for software. What classification is a DVD? 3
4
Exam Topics Software: OS, apps, compilers Describe the purpose of a compiler. What differentiates the Operating System (OS) from an application (app)? 4
5
Exam Topics Language generations Sort the following languages in order of generation, low to high: English MATLAB Machine Assembly 5
6
Exam Topics What piece of hardware is the basis for modern computers? Why do say that computers work in "binary"?
7
Exam Topics 5-step Process: Identify and describe the five steps for this problem: I need a computer program that will compute the volume of any right regular prism with 10 sides or less. 7
8
8 Exam Topics Developing Solutions I/O Diagrams 5-Step Process State the Problem Identify inputs & outputs Manually solve the problem Computerize: Algorithm & code Test, test, test! Syntax Semantics
9
9 Exam Topics Developing Solutions
10
10 Exam Topics Developing Solutions
11
Exam Topics I/O Diagrams Prepare an I/O diagram for the program desired: I need a program to compute the time required to get to Mars and how much fuel is needed, assuming I leave six months from the day the program is run. 11
12
Exam Topics Know variable and file naming constraints Understand the functions listed in the lecture notes [e.g. sin(), cos(), sind(), cosd(), sqrt(), etc] – know the difference between sin() and sind(), for example. What is ans ? What does clear do? What about clc ? How do you suppress default output? 12
13
Exam Topics A data type is a category of information. The data type determines how information is stored in the computer and how it can be used. Integers whole numbers Floats numbers with fractional portion Strings sequences of characters 13
14
14 Exam Topics Starting with MATLAB
15
15 Exam Topics Starting with MATLAB
16
16 Exam Topics I/O
17
17 Exam Topics Input and Output The input() function What is a "prompt"? "Collecting the return value" Strings vs. Numbers The disp() function
18
Exam Topics The input function: Provide the MATLAB code that will use the input() function to obtain from the user the cost (in dollars) for an item, storing the information in the variable cost_per_item. Provide the MATLAB code that will use the input() function to obtain from the user the name for an item, storing the information in the variable item_name. 18
19
Exam Topics Simple output: disp() Tricky question: Use the disp() function to display the value of π to four decimal places. 19
20
20 Exam Topics Input and Output The fprintf() function The format string Placeholders Format modifiers left justification width specifier precision specifier Escape sequences
21
Exam Topics Formatted output: fprintf() fprintf(‘%11s said he made $%-7.2f/year\n’, name, paycheck); From the MATLAB command above, identify … All placeholders All format modifiers All escape sequences 21
22
Exam Topics Using fprintf() and the provided variables for the red portions, provide the MATLAB statement that will display this sentence: _ _ _ _John wants Jill_ _ _ to run up the hill 16 times (where _ indicates a blank space) A = ‘John’ B = ‘Jill’ C = ‘up’ D = 4 22
23
Exam Topics Assuming the variables used are name, age, and income, provide an fprintf() statement that contains no spaces and will align the columns for any line in the table. Fred Flintstone 47$100000.32 Barney "The Man" Rubble148 $ 3.25
24
Exam Topics Unary vs Binary operators &, &&, |, ||, +, -, *, /, ~, <, =, == From the set of operators above… Which one(s) can be used as either unary or binary operators? Which one(s) are only unary operators? 24
25
Exam Topics Numeric: Identify each of these operators Multiplication (scalar) Multiplication (matrix) Division (scalar) Division (matrix) Addition (scalar) Addition (matrix) Subtraction (scalar) Subtraction (matrix) Exponentiation (scalar) Exponentiation (matrix) Assignment 25
26
Exam Topics Name these operators: Relational <, >, <=, >=, ==, ~= Boolean &&, ||, ~ Know the true and false keywords 26
27
27 Exam Topics Operators
28
Exam Topics Functions name = input(‘Enter a username:\n’, ‘s’); In the MATLAB statement above, which symbol(s) indicate… - the arguments - collecting return values - the function call 28
29
Exam Topics Modulus How would you determine if a user-provided value (stored in the variable x ) is divisible by 17? 29
30
30 Exam Topics Conditionals The IF statement What is the purpose of the IF statement? When should we choose an IF over a SWITCH? Do IF statements repeat? What code can go in IF, ELSEIF, and ELSE clauses?
31
Exam Topics IF / ELSEIF / ELSE: Construct an IF statement that will print ‘Yes’ if the shuttle will launch; ‘No’ if the shuttle will not launch; ‘Maybe’ if it is unsure. Use a variable of your own choosing. 31
32
32 Exam Topics Conditionals Boolean expressions Using &&, ||, and ~ What is the output of this code? a = true; b = 1; c = -4; if a && ~(b>c) disp('IF'); else disp('ELSE'); end
33
33 Exam Topics Conditionals
34
34 Exam Topics Conditionals Boolean expressions Can we do this? if a == 1 || 2 || 3 disp('Yes'); else disp('No'); end How about: if 0 < a < b
35
35 Exam Topics Conditionals The SWITCH statement What is the purpose of the SWITCH statement? When should we choose an SWITCH over an IF? Do SWITCH statements repeat? What goes after the word "switch"? What code can go in the cases?
36
Exam Topics SWITCH / CASE: Provide a SWITCH-CASE statement that will process the menu below. Use a variable of your own choosing. Press 1 to Jump Press 2 to Duck Press anything else to walk forward 36
37
37 Exam Topics Library Functions What is a function? Why use functions? What are library functions?
38
38 Exam Topics Library Functions What is a function call? What is an argument? What is a return value? Can we have more than one? What does it mean to "collect" the return value? Must we provide arguments? Must we collect the return value?
39
39 Exam Topics Library Functions
40
40 Exam Topics Nesting What does this mean? What can we nest? What syntax issue should we watch?
41
Review for Exam 1 End of Presentation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.