RobotC Lecture 2

RobotC Lecture 2 - Array Review Lets write a program to...

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

View Full Document Right Arrow Icon
Array Review • Let’s write a program to create an array of ten integers storing consecutive numbers. ..
Background image of page 1

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

View Full DocumentRight Arrow Icon
Array Review int main() { intnums[10]; for (int i=0; i<10; i++) nums[i]=i; }
Background image of page 2
Array Review int main() { int nums[10]; for (int i=0; i<10; i++) Index Memory Contents 0 1 2 nums 0 1 2 nums[i]=i; } 3 4 ... 9 3 4 9
Background image of page 3

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

View Full DocumentRight Arrow Icon
Array Output • What would we have to add to the previous program to get the array contents output to the console? Add: for (int i=0; i<10; i++) cout<<nums[i]<<endl;
Background image of page 4
Very important • Notice in the previous example, any time we were filling or outputting the array, we had a loop n array is NOT “One Thing” it is MANY – An array is NOT “One Thing” it is MANY variables, grouped together under one name The only time we can affect an entire array at once is when we are initializing: Ex . int array[100]={0}; Sets entire array to 0
Background image of page 5

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

View Full DocumentRight Arrow Icon
Sensors Sensors convert physical property to electrical, either voltage or current Voltage: Difference in electric potential per unit charge between two points Current: amount of electrical charge transferred per unit of time
Background image of page 6
Example: Tachometer otation oltage Sensor Tachometer Rotation Speed Voltage
Background image of page 7

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

View Full DocumentRight Arrow Icon
Signal and Noise The sensor output consists of: • Signal
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2012 for the course GENE 121 taught by Professor Smucker during the Winter '11 term at Waterloo.

Page1 / 24

RobotC Lecture 2 - Array Review Lets write a program to...

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

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