Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1.

Similar presentations


Presentation on theme: "An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1."— Presentation transcript:

1 An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1

2 An Introduction to Programming with C++2 Objectives Explain the sequence, selection, and repetition structures Write simple algorithms using the sequence, selection, and repetition structures

3 An Introduction to Programming with C++3 Concept Lesson

4 An Introduction to Programming with C++4 Defining Control Structures All computer programs, no matter how simple or how complex, are written using one or more of three basic structures: –Sequence –Selection –Repetition

5 An Introduction to Programming with C++5 The Sequence Structure Directs the computer to process the program instructions, one after another, in the order listed in the program Rob, the mechanical man: –Has limited instruction set (walk, turn, and sit)

6 An Introduction to Programming with C++6 The Sequence Structure

7 An Introduction to Programming with C++7 The Repetition Structure Makes a decision, then takes appropriate action based on that decision –Example: shampoo bottles typically include the repetition structure in the directions for washing your hair

8 An Introduction to Programming with C++8 The Repetition Structure

9 An Introduction to Programming with C++9 The Repetition Structure

10 An Introduction to Programming with C++10 Rob’s New Instruction Set

11 An Introduction to Programming with C++11 The Selection Structure Directs the computer to repeat one or more instructions until some condition is met, at which time the computer should stop repeating the instructions –Example: Selection structure is used every time you drive your car and approach an intersection

12 An Introduction to Programming with C++12 The Selection Structure

13 An Introduction to Programming with C++13 Application Lesson

14 An Introduction to Programming with C++14 Programming Rob the Mechanical Man To install the Rob the Mechanical Man files on your computer’s hard disk: 1.Click the Start button on the taskbar, and then click Run to open the Run dialog box 2.Click the Browse button to open the Browse dialog box. Open the Rob Installation Files folder, which is located in the CppNet folder on your computer’s hard disk

15 An Introduction to Programming with C++15 3.Click Setup (Setup.exe) in the list of filenames, and then click the Open button to return to the Run dialog box 4.Click the OK button in the Run dialog box. A message box appears and indicates that seven files are being copied to your computer’s hard disk 5.Read the message in the dialog box. If necessary, close any open files, then click the OK button in the dialog box Programming Rob the Mechanical Man

16 An Introduction to Programming with C++16 Installation Message

17 An Introduction to Programming with C++17 Programming Rob the Mechanical Man (Cont.) As the dialog box indicates, the files will be installed in the Program Files\Rob directory (folder) on your computer’s hard disk. You can use the Change Directory button to install the files in another directory 6.If desired, change the default installation directory to one of your choosing

18 An Introduction to Programming with C++18 7.Click the Click here to begin setup button in the dialog box. The Rob the Mechanical Man – Choose Program Group dialog box opens and shows Rob the Mechanical Man selected in the list of groups 8.Click the Continue button. When the message “Rob the Mechanical Man Setup was completed successfully” appears, click the OK button Programming Rob the Mechanical Man (Cont.)

19 An Introduction to Programming with C++19 Rob and the Flower Bed

20 An Introduction to Programming with C++20 Running the Application To run the application that you will use to create Rob’s algorithm: 1.Click the Start button on the taskbar, and then point to All Programs on the Start menu 2.Point to Rob the Mechanical Man on the All Programs menu, and then click Application Lesson. The Rob the Mechanical Man application shown in Figure 1-13 appears on your screen

21 An Introduction to Programming with C++21 Rob the Mechanical Man Application

22 An Introduction to Programming with C++22 Initial Algorithm for Rob

23 An Introduction to Programming with C++23 Initial Algorithm for Rob (Cont.)

24 An Introduction to Programming with C++24 Final Algorithm for Rob

25 An Introduction to Programming with C++25 Entering the Algorithm To enter the algorithm shown in Figure 1-15, and then verify that it works correctly: 1.Scroll down the Instruction Set list box until you see the repeat 6 times: instruction. Double-click repeat 6 times: in the Instruction Set list box 1.Double-click if the flower is red, then do this: (inside loop) to copy this instruction to the Algorithm list box 1.Double-click pick up the flower with your right hand (inside loop|selection) to copy this instruction to the Algorithm list box 1.Double-click otherwise, do this: (inside loop), then double- click pick up the flower with your left hand (inside loop|selection)

26 An Introduction to Programming with C++26 Entering the Algorithm (Cont.) 1.Scroll down the Instruction Set list box, if necessary, until you locate the walk (inside loop|selection) instruction, then double-click walk (inside loop|selection) 1.Double-click walk (outside loop|selection) 1.Click the Verify Algorithm button. The Verify message box opens and displays the “Great job!” message. Click the OK button to close the message box 1.Click the Exit button to close the application

27 An Introduction to Programming with C++27 First Instruction

28 An Introduction to Programming with C++28 Completed Algorithm

29 An Introduction to Programming with C++29 Uninstalling Rob the Mechanical Man 1.Click the Start button, and then click Control Panel on the Start menu 2.Click Add or Remove Programs to open the Add or Remove Programs window 3.Scroll down the list of currently installed programs, if necessary, then click Rob the Mechanical Man in the list. Click the Change/Remove button. When you are asked if you are sure you want to remove Rob the Mechanical Man and all of its components, click the Yes button 4.When the “Program installation removed” message appears, click the OK button 5.Click the Close button to close the Add or Remove Programs window, then close the Control Panel window

30 An Introduction to Programming with C++30 Summary Basic components of all algorithmic problem solutions: –Sequence Process instructions one after another –Selection Take an action based on a decision –Repetition Repeat a set of instructions until a condition is met Write simple algorithms using the sequence, selection, and repetition structures


Download ppt "An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1."

Similar presentations


Ads by Google