Lecture7_handout

Lecture7_handout - Overview EE140: Introduction to to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 EE140: Introduction to 0t o d u c t o t o Programming Concepts for Engineers Lecture 7 1 Functions Overview Function must be defined (each input parameter usthaveadatatype) must have a data type) Function name is unique, do not use function name as the variable name When call the function, the parameters must match those in the function header Number of parameters must be the same rder of the parameters must be the same 2 Order of the parameters must be the same Type of each parameter passing to the function must match (or can be casted) Return type must match (or can be casted) Example 1: Resistor Colors Write a program to read in an integer value of the resistor and find out the first three color bands printed on the resistor Band 1: first digit Band 2: second digit Band 3: multiplier Band 4: Precision Value= 2300 =23 × 10 2 Band1=2, Band2=3, Band3=2 So colors are Red, Orange, Red 3 Color Black Brown Red Orange Yellow Green Blue Violet Grey White B a n d 0123456789 Two functions: 1. Function to look up the color for a given value of the band Implementation pg -- input: an integer digit in the range 0 - 9
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course EE 150 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

Page1 / 4

Lecture7_handout - Overview EE140: Introduction to to...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online