Lecture notes in C++ Programming

how to learn c++ programming and lecture notes on object oriented programming in c++ and object oriented programming c++ lecture notes pdf
AndyCole Profile Pic
AndyCole,United Kingdom,Professional
Published Date:09-07-2017
Your Website URL(Optional)
Comment
Practical C++ Programming Teacher's Guide Introduction This guide is designed to help with the classroom presentation of the material in Pracctical C++ Programming. It contains a set of teacher's notes for each chapter which give you information about the key concepts covered in the chapter as well some ideas for in-class demonstration. The live demonstration section alrets you to the live programs available for demonsration in class. There is also a set of review questions for each chapter with answers. (The “Quiz” document contains these questions without answers.) Hopefully this guide will make your teaching of C++ a little easier. Table of Contents Chapter 1: What is C++?..............................................................................................................................3 Chapter 2: The Basics of Program Writing..................................................................................................4 Chapter 3: Style............................................................................................................................................7 Chapter 4: Basic Declarations and Expressions...........................................................................................9 Chapter 5: Arrays, Qualifiers, and Reading Numbers...............................................................................14 Chapter 6: Decision and Control Statements ............................................................................................19 Chapter 7: The Programming Process........................................................................................................21 Chapter 8: More Control Statements..........................................................................................................24 Chapter 9: Variable Scope and Functions .................................................................................................27 Chapter 10: The C++ Preprocessor............................................................................................................34 Chapter 11: Bit Operations.........................................................................................................................36 Chapter 12: Advanced Types ....................................................................................................................38 Chapter 13: Simple Classes........................................................................................................................40 Chapter 14: More on Classes.....................................................................................................................43 Chapter 15: Simple Pointers.......................................................................................................................45 Chapter 16: File Input/Output....................................................................................................................48 Chapter 17: Debugging and Optimization.................................................................................................51 Chapter 18: Operator Overloading.............................................................................................................53 Chapter 19: Floating Point.........................................................................................................................55 Chapter 20: Advanced Pointers..................................................................................................................56 Chapter 21: Advanced Classes...................................................................................................................58 Chapter 22: Exceptions..............................................................................................................................60 Chapter 23: Modular Programming...........................................................................................................61 Chapter 24: Templates...............................................................................................................................63 Chapter 25: Standard Template Library.....................................................................................................64 Chapter 26: Program Design......................................................................................................................65 Chapter 27: Putting It All Together...........................................................................................................67 Chapter 28: From C to C++.......................................................................................................................68 Chapter 29: C++’s Dustier Corners..........................................................................................................70 Chapter 29: Programming Adages ............................................................................................................71 Supplement: From C to C++......................................................................................................................72 Page 2Chapter 1: What is C++? Profanity is the one language that all programmers understand. Anon. Teacher’s Notes This chapter is designed to give students some idea of where C++ fits in the world of programing. You might want to take this opportunity to tell your class about your personal experience with C++. For example, when did you first encounter the language, what where you doing with it, how did it make your life better? This is also the time to acquaint the students with what the course is going to cover and what is expected of them. Good style and programming practices are stressed in this book. I’ve gone through a lot of other people’s code and am a fanatic about creating simple, readable programs. I grade 60% on style and 40% on function. Style covers things like, “Is the program readable? Is it simple and easy to understand? Are there comments at the beginning of each function? Are there comments after each variable declaration?” and so on. Functionality covers whether or not the program works and works efficiently. Finally this is the time to acquaint the students with the local computing facilities. They should know where the machines are and where to go for help. Review Questions 1. Define “class.” A set of data and the functions that work on that data. 2. Where are the computers that are to be used for homework for this course? 3. What compiler are we using for this course? Page 3Chapter 2: The Basics of Program Writing The first and most important thing of all, at least for writers today, is to strip language clean, to lay it bare down to the bone. — Ernest Hemingway Teacher’s Notes In this chapter we give students an idea of what a programming language is. We try to give students an idea of the work done to translate a high-level programing language into an executable program. Finally, we have a section that describes in extreme detail the steps needed to run a compiler. Four specific compilers, Borland-C++, Microsoft Visual C++ .NET, GNU’s g++, and a generic UNIX CC compiler, are described. Computers require precise instructions in order to work. We start by introducing the students to a language they probably already know: English. Even with English, precise instructions are hard to create. Programming languages have evolved over the years. In the beginning everyone programed in machine language. This evolved through assembly language, higher level language, the C language, to the C++ language. This chapter gives a brief description of each of these stages. Next the students are introduced to the tools used to create programs. At this point I suggest that you tell the students the absolute minimum needed to actually use the tools and no more. After that they can either learn by reading the manual or you can give little ten minute mini-lectures at the beginning of future classes. But for now they need to know only how to use the editor, compiler, linker, and the make utility. If they are programming in DOS or Microsoft Windows, a short tour of the various components of the Integrated Development Environment is in order. At this point it would be good to demonstrate creating a program. I suggest that you deliberately include a mistake. This gives you a chance to show the students what an error message looks like and how to correct it. When the chapter is finished the students should be able to type in a program and get it to run. The program won’t be understandable to the student at this point, but it will be enough to get something to run. Live Demonstration Slide 13 hello/hello.cpp Page 4Classroom Presentation Suggestions Before the class, go through the slides and remove any “Compiling the program using ....” slides that do not pertain to your local setting. If you are using a commerical compiler (Borland, Microsoft), check the slides to make sure that informatioin them is still current. Starting with the slide on Construction Tools (Slide 9) you may want to demonstrate the creation of an actual program. Show how to edit, compile, get an error, edit again, compile, and run a program. After this lecture, the class should adjourn to the computer lab where they will type in their first program under the watchful eye of the instructor. This is the time they will need the most hand-holding as they will make a large number of simple errors trying to get the compiler to run. Review Questions 1. Define “Machine Language.” A language consisting of a series of numbers. These numbers represent the actual instructions used by the computer. Easy for computers to understand, but very difficult for humans. 2. Define “Assembly Language.” A language in which a single instruction translates directly into a single machine instruction. 3. Define “source code.” The high level code written by the programmer. In a high-level language, the source code is usually machine independent. 4. Define “object code.” The source code after it has been translated into machine language. 5. Define “library.” A collection of generally useful procedures available to the programmer 6. Define “linker.” A program that combines one or more object files with a set of libraries and produces an executable program. 7. Define “executable program.” A machine dependent file that contains all the instructions necessary to perform a task. 8. How is assembly language different from machine language? Machine language is solely numbers. Assembly language uses words to represent those numbers. Page 59. What does a compiler do? It takes a source file and transforms it into an object file. Note: many “compilers” are actually wrappers that run a compiler and a linker. 10. How is a compiler different from an assembler? One assembly instruction translates to one machine language instruction. Assembly language is a low-level language. A compiler translates one statement into many instructions. Compilers are also machine-independent, while assemblers are machine-dependent. 11. What is the extension for source files on our machine? The extension “.cpp”. Although .C and .cc are sometimes used on UNIX / Linux. 12. What type of program is used to create “source code.” A text editor. Note: many Microsoft Windows compilers supply an Integrated Development Environment (IDE) that contains a text editor (among other things). In spite of all the wrapping, however, it’s still a text editor. 13. What is the extension for object files on our machine? DOS/Windows uses “.OBJ”. UNIX uses “.o”. 14. What type of programs are used to produce object files? Compilers. 15. What is the extension for the executable programs? DOS/Windows uses “.EXE”. UNIX uses no extension. 16. What type of files go into creating an executable program? Programs start out as “source.” They get translated into “object” files by the compiler. These are combined with “libraries” by the linker into an “executable program.” 17. What type of program is used to create an executable program? The compiler starts the process, but it produces object files. The linker is the program that actually produces the executable programs. Note: the actual linking step may be hidden since the UNIX CC wrapper and the DOS Inte gr ated Development Environments run the linker behind your back. 18. How do you access the on-line help system for your compiler? Most DOS/Windows Integrated Development Environments have a built-in help system. On UNIX you can use the “man” command. Page 6Chapter 3: Style There is no programming language, no matter how structured, that will prevent programmers from writing bad programs. - L. Flon It is the nobility of their style which will make our writers of 1840 unreadable forty years from now. - Stendhal Teacher’s Notes As a professional programmer I have had to maintain a lot of code. Most of it in very poor condition. Hopefully, by teaching commenting and style early we can convince future programmers to write well commented, easy to read programs. In this chapter we describe how to comment programs. It may seem strange to learn how to comment before we know how to program, but the comments are the most important part of the program. That last statement deserves repeating, Comments are the most important part of the program. I grade homework 60% on comments and 40% on code. At this point it may seem that I’m somewhat of a fanatic on commenting. I am. You get this way after spending years going through uncommented code while trying to maintain it. The purpose of this chapter is to convince your students to put copious comments in the code. Comments should be written as an integral part of the programming process. Time and time again I’ve heard, “Here’s my homework, but I didn’t have time to put in the comments.” My answer, “You should put in the comments first. I don’t mind too much if you put in the comments and don’t have enough time to do the code, but don’t leave out the comments — ever” When I was grading homework I had a rubber stamp made up: If you teach your students one thing it should be to make their programs clear and easy to understand. Comments are an essential part of that process. Classroom Presentation Suggestions There should be a style sheet for the class. This can be created by the class or supplied by the instructor. It should include a list of what you as a teacher want for the heading comments of each assignment. Suggestions include: • The student’s name • The assignment number • Student ID number • All the other stuff detailed in this chapter Review Questions Page 71. Why are comments required in a program? Comments provide the programmer with a clear, easy-to-read description of what the program does. They are required because uncommented programs are hard to understand (sometimes even the person who wrote them can’t understand them). Uncommented programs are also extremely difficult to maintain. As the age and complexity of software programs skyrockets, maintenance (and comments) becomes much more important. ( 2. Why must you write comments before or while you write the program, never after? Because at the time you write the code you know what you are doing. If you leave the commenting until later, you may forget and have to guess. 3. Which is better: 1) The underscore method of writing names, such as: this_is_a_var, or 2) The upper/lower case method: ThisIsATest? I like this_is_a_var myself because you can run your program through a spelling checker. I think it is more readable. Also it allows you to use lower case only for variables and upper case only for constants. Some people think that ThisIsATest is more readable . This is a religious issue and has no right answer. Page 8Chapter 4: Basic Declarations and Expressions A journey of a thousand miles must begin with a single step. — Lao-zi If carpenters made buildings the way programmers make programs, the first woodpecker to come along would destroy all of civilization. — Anon. Teacher’s Notes In this chapter students are introduced to the concept of a program. Programs consist of three parts: comments, data, and code. We’ve already covered comments. They are the most important part of a program and are used to document the things that the program does. They are written for human beings like maintenance programmers and C++ instructors. To simplify things as much as possible we present only one type of data, simple variables declared globally. Later we’ll see how we can declare complex variables such as structures and classes. We’ll also look at the difference between local and global variables. But for now we just want to get the concept of a variable across. Similarly, the code part has also been simplified. Our programs consist of only one function, main. We also limit ourselves to simple expressions and assignment statements, which, along with the std::cout statement are all we need to write programs. True, they are very limited programs, but they still give your students a chance to make a lot of mistakes. Because the students know next to nothing about programming at this point, we use the “trust me” method of teaching several key elements. For example, the executable part of the program begins with: int main() Rather than confuse the student with what this actually does, we say “trust me, it works”. Actually, we are declaring the beginning of the function main. This function is just like any other C++ function except that the special name causes C++ to call it first. All other functions are called directly or indirectly from main. At the end of the program we have another “trust me.” We end programs with: Page 9 return(0); Actually, this returns a value of zero to the caller (the operating system). The 0 indicates a successful execution. If an error occurs we would return a positive number. The bigger the number, the more severe the error. Live Demonstration Slide 14 tterm/tterm.cpp Classroom Presentation Suggestions Keep it simple. The students are about to write their first programs, and they will tend to have a lot of very basic problems. Review Questions 1. Name and define the three elements of a program. Functions, data declarations, and comments. 2. Why are comments required in a program? Without them programs are next to impossible to debug, maintain, or enhance. 3. What is the purpose of the return(0); near the end of each program? It returns a status code of 0 ( good return) to the operating system. 4. What punctuation character signals the end of each statement? A semicolon (;). 5. What statement to you use to print something to the screen? std::cout statement . 6. What are the five simple C++ operators? Multiplication (), division (/), addition (+), subtraction (-), and modulus (%). 7. Evaluate the following C++ expressions: a. 5 + 3 / 2 + 1 7 b. (5 + 3) / ( 2 + 1) 2 c. 8 % (3 4) + 8 / 3 - 9 1 Page 10d. 8 / (3 4 + 8 / 3 - 9) 1 e. 4 + 9 6 - 8 50 f. (11 % 7) / 3 1 8. What will the following statements print? (Assume i=5 and j=7.) a. std::cout i '\n'; 5 b. std::cout "i" '\n'; i c. std::cout i / j '\n'; 0 d. std::cout "i=" i; i=5 Warning: There is no newline at the end of this statement, so the next std::cout output will run right up against the 5. (Example: i=5Hello World .) e. std::cout "i=" i '\n'; i=5 Notice that the newline is added, so this will be a complete line . 1 2 d= ⋅g t 9. Turn the equation into a C++ statement. 2 d = 1.0 / 2.0 g t t; or using better variable names: distance = 1.0 / 2.0 GRAVITY time time; 10. What does it mean when you see the message “Warning: Null effect”? A statement is correctly written, but useless. For example, a statement that computes a value then throws it away. 11. Define “variable.” A named area of memory used to store values. Page 1112. Define “variable declaration.” A C++ statement that describes a variable. It is used to tell C++ what variables we are going to use in our program. 13. What are the three purposes for a variable declaration? The type of the variable ( int ), the name of the variable ( total_count ) , and a comment describing the variable. 14. The FORTRAN language (among others) would automatically declare a variable the first time it was used. Variables that began with A-H,O-Z where automatically declared float and variables that begin with I-M were automatically declared int. Discuss the advantages and disadvantages of this “feature.” (Note: FORTRAN was invented before lowercase was widely used in computes, so all variables were written in uppercase only.) Advantages You don’t have to declare variables . Disadvantages You got names like KOUNT t o force the count variable to be an integer type. Misspelling of variable names could not be caught by the compiler. Note: When I was writing FORTRAN programs I wanted to force the compiler to require that all variable names be declared. I did this by the statement: IMPLICIT COMPLEX (A-Z) This told the compiler that any variable that was not declared was to be considered a complex variable. Because complex variables required a special syntax and because I didn’t use them, any misspelled variable name showed up as a compiler error: Misuse of a complex variable. 15. Define std::cout and use it in a C++ statement. std::cout is the C++ class that is used for writing data to the screen. Example : std::cout "Hello World\n"; 16. Define “assignment statement” and give an example. Assignment statements take expressions and put them in variables. Example: result = 45 / 36; 17. What is the difference between a real and an integer variable? Integer variables can only hold whole number or integers such as 1, 5, 98, and -42. Real or floating point variables can hold fractional numbers such as 5.3, 8.6, and 45.2. Note: Any number with a decimal point is floating point, even if it looks like 5.0. 18. Give an example of an integer division statement and a floating point division statement? i_var = 12 / 5; // Integer Division Page 12f_var = 12.0 / 5.0; // Floating point division 19. The same operator ‘/’ is used for both floating point and integer divides. How does the compiler know which one to use? The compiler checks both sides of the division to see if either the divisor or the dividend is a floating point number. If either one is floating point, then a floating point divide is performed. If both operands are integers then an integer divide is done. 20. A thermos keeps hot things hot and cold things cold. How does it know which one to do? 21. The standard character set, ASCII, handles 128 characters. Only 95 of these can be typed in using the keyboard. What does a C++ programmer use to specify the none printing characters? The backslash character (called the escape character sometimes) is used to indicate a special character. For example “\b” is used to indicate the non-printing “backspace” character. 22. Define “character variable” and show how a character variable can be declared and used. A variable that can hold a single character. char a_char; // Sample character declaration //... a_char = 'x'; Characters may also be used as “very short integers.” That is, numbers in the range of 0- 127. Example: a_char = 5; 23. What are the possible value of a boolean (bool) variable? true and false . (Do NOT use "True", "False", "TRUE", or "FALSE". If you see these they are legacy constants for ancient code.) Advanced Questions The answers to these may require resources outside the scope of this book. 24. What is the value of 4.5 % 3.2? 25. Why are real numbers called floating point numbers? 26. What “floats” in a floating point number? 27. What is the biggest integer variable that you can have on your machine? 28. What is the biggest floating point variable that you can have on your machine? 29. Why are integer variables exact and floating point variables inexact? Page 13Chapter 5: Arrays, Qualifiers, and Reading Numbers That mysterious independent variable of political calculations, Public Opinion. — Thomas Henry Huxley Teacher’s Notes In the previous chapter students were introduced to the simple variable and the output statement. In this chapter we expand on that knowledge by introducing them to the array type and the input statement std::cin. C++ has two basic types of strings. The first, the C++ Style String is a class found in the string header file: include string std::string name = "Steve Oualline"; The other type is the C Style String which is created from an array of characters. char name50 = "Steve Oualline"; C++ style strings are introduced first since they are simpler to use and less error prone than C style strings. One of the things new to this edition is the introduction of safety code. Starting with the section Bounds Errors (page 54) the assert statement explained. Since I wrote the first edition, I have encounter a huge mass of badly written code. It was only the extensive use of asserts which made it possible to debug the thing. These statements prevented array boundary errors which could cause random problems in the code. The use of error checking code and asserts should be highly encouraged. The book discusses C Style strings because there are a lot of programs out there that use them. Your students should avoid them because they force you to handle your own storage. (C++ Style strings automatically allocate their own storage.) This chapter introduces the student to all the modifiers such as short, long, and register. Some, like short and double, the student can use immediately. Some, like register, will be discussed in later chapters. A few, like volatile, are so advanced that this course does not cover them at all. At this stage of the game, reference declarations are not useful. In fact putting them in a program tends to confuse things. However, you will find them very useful when we start using them to declare function Page 14parameters later in the book. All of the modifiers have been included in this chapter for completeness. C++ contains a large number of shortcut operators. This makes programming more compact and concise. Unfortunately, the overuse of these operators can cause problems. Verbose programs that work are much better than terse programs that do not. I believe that the goal of programming is not compactness, but clarity and a working program. For that reason I don’t allow my students to use shortcut operators such as ++ and inside other statements. Side effects such as those caused by ++ and inside other statements can easily cause trouble. What’s worse, the type of trouble they cause is difficult to detect. Avoid side effects. Live Demonstration Slide 3 five/five.cpp Slide 24 name2/name2.cpp Slide 26 len/len.cpp Classroom Presentation Suggestions On Slide 20 we ask the question “Are all ‘C Style strings’ ‘arrays of characters’?” The answer is “Yes.” A string is a special form of an array of characters. A string starts at the first element of the array and continues until the end-of-string character (‘\0’). Note: The declaration char data10; defines a 10-character array. As an array it holds 10 characters, no more, no less. It can hold strings of length 0 to 9. Why not 10? Because we need one location to store the end-of-string character. Are all “character arrays” “C Style strings”? No. Consider the following character array: char data4 = ‘A’, ‘B’, ‘C’, ‘D’; In this case we have an array containing four characters. It does not contain a string. There is no end-of- string character. How can the compiler tell the difference between a character array and a string? It can’t. If we tried to treat data as a string, the compiler would let us. We would, however, get strange results. Question on Slide 9 of the slides The variable width is undefined because it is in the middle of a comment. Check out the comment end on the previous line. Question on Slide 18 of the slides The question is, why does array2,4print out a funny value? C++ uses the syntax array24 Page 15to select a single element of the array. When C++ sees the expression 2,4 it uses the comma operator (see Chapter 28, C++’s Dustier Corners) to evaluate the expression. The result is 4. So array2,4 is the same as array4. This, unfortunately, is a pointer and C++ prints it as a pointer, which results in the strange printout. Question on Slide 32 of the slides Answer “c.” I’m a great believer in practical programming and follow the adage. “If you don’t write stupid code, you don’t have to answer stupid questions.” The “real” answer to this question, according to the ANSI draft standard, is that there are three flavors of characters, char, unsigned char, and signed char, and compilers should generate a warning if you try to mix flavors. Many real compilers don’t follow the standard. Some generate signed characters, some unsigned, and the Borland compiler has a switch that allows you to specify signed or unsigned as the default. Side Effects If possible, include a story from your programming experience titled “How I found a nasty bug caused by a side effect and why I want to strangle the programmer who put it in.” Review Questions 1. What is the difference between an array and a simple variable? A simple variable holds only one value. Arrays hold many values. 2. What is the number of the last element of the following array? int test5; “ 4” (The elements go from 0 to 4). 3. What's the header file that's used to bring in the data definitions for C++ strings? include string 4. How do you concatenate two C++ style string? Use the “+” operator. Page 165. What is the difference between a C style string and an array of characters? Arrays of characters are fixed length. C++ makes no restrictions on what can be placed in any array of characters. Strings are stored in arrays of characters. The end of a string is indicated by an end of string character (‘\0’). Because strings use this marker strings can be any length up to the size of the array they are stored in (—1 for the end of string marker). 6. Why must we use std::strcpy to assign one C style string to another? C++ does not have an array assignment operator, so it’s impossible to assign one character array to another. 7. We define a character array whose job is to hold a string. What is the difference between the size of the array and the length of a C style string? The size of the array is fixed and set to the size declared at compile time. The length of a string can change depending on where we place the end of string character. 8. Can the size of any array change during the execution of a program? No. 9. Can the length of a string variable change during the execution of a program? Yes. 10. What happens if you try to read a C++ style string using std::cin and the operator? (Try it) What about the C style strings? The input line, up to the first space or other whitespace character, is read into the string. 11. How many elements are allocated for the multiple dimension array: int four_dimensions25864896; Bonus question: Why will you probably never see a declaration like this in a real program? This array defines 3,863,808 elements. (25864896) On a machine that uses 4 bytes per integer that’s 15,455,232 bytes or 15MB. That’s a lot of memory for a single array. 12. Define the following: long int short int unsigned signed float double register auto volatile const reference extern l ong int a signed integer that may hold more data than an ordinary integer . s hort int a signed integer that may hold less data than an ordinary integer . Page 17u nsigned variable that may hold only positive value. By sacrificing the sign bit, the numbe r can hold twice as many positive values. s igned a number that may hold positive and negative values. Since this is the default for integers and floating point variables, it is rarely used. f loat a variable type that can hold real or fractional values . d ouble a real variable type that has more range and precision than “float.” r egister a suggestion from the programmer to the compiler indicating that this variable is used a lot so it would be a good idea to put it in a machine register. auto a variable that is automatically allocated from the stack. vol atile a special variable whose value may be changed by things outside the program . Used for things like memory mapped I/O. c onst a named value that cannot be changed. r eference an alias or second name for an already declared variable . extern a variable that is defined in another file. Actually, C++ won’t get mad at you i f you define it in the current file. 13. Why must you use the notation static_castint(very_short) to write a very short number (a.k.a. a character variable)? What would happen if you wrote it out without the int wrapper? The static_cast int(x) notation changes the character variable’s type from character to integer for the purpose of the write. If the int wrapper is left off, the C++ would write the character variable out not as a very short integer but as a single character. After all, C++ does not know if you are using a character variable to hold a character or a very short int. 14. Define side effect. A side effect is an operation that occurs in addition to the main operation specified in a statement. 15. Why are side effects bad things? The confuse the code and can easily cause unexpected things to happen. Using them can make the code dependent on things like the evaluation order of operands. They save space in the source code at the expense of clarity and reliability. Page 18Chapter 6: Decision and Control Statements Once a decision was made, I did not worry about it afterward. — Harry Truman Teacher’s Notes Student are now introduced to the fact that computers cannot only do computitions, but can also make decisions. Decision statements for the most part are fairly straight-forward and fairly simple, as are the relation operators. A conditional statement works on the single statement that follows it. Multiple statements my be grouped together by curly braces () and treated as a single statement. The if/else statement is ambiguous as we can see in Slide 7. One of the things emphasized in this book is practical programming, and practically speaking you don’t have to worry about language weirdness if you avoid it. Note: For the purist in your class, the ambiguity is resolved by placing the else clause with the nearest if. (Answer b). Then show the students how to use decision and control statements by writing a program to print out a series of Fibonacci numbers. Finally, teach the student the dangers of using = inside an if or while statement. The one mistake you will make, and your students will make, is putting = where you meant to put ==. Emphasize this at every opportunity. I remember after one class a student came up to me and said, “Steve, I have to admit that I thought you were a little crazy going on and on about = vs. ==. That was until yesterday. You see I just wrote my first C program for work and guess what mistake I made.” Live Demonstration Slide 12 fib/fib.cpp Slide 14 total/total.cpp Slide 16balance/balance.cpp Review Questions 1. Define the following: Branching Statements Page 19Looping Statements if statement else clause relational operator logical operator while statement Fibonacci number break statement Branching Statements c hange the control flow of a program by executing one or more different branches of the code. Looping Statements s tatements that cause the flow of the program to repeat or loop over a section of code. if statement a statement conditionally executes a block of code . else clause a clause at the end of an if statement that defines a section of code to be executed if the condition in the if is not true. relational operator operators such as ==, =, and , that compare two values. These operators are used to test the relationship between two values. logical operators Operators perform the logical functions “and,” “or,” and “not”. while statement a looping statement that will repeatedly execute a section of code until its condition becomes false. Fibonacci number a number in a series that starts out with “1 1”. Each element of the series from here on is the sum of the previous two numbers. break statement a statement that when executed exits a loop. Page 20

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.