 Monday, 9/9/02, Slide #1 CS106 Introduction to CS1 Monday, 9/9/02  QUESTIONS?? (Exercises, Lab #1, etc.)  Today:  More on float objects  C++ concept:

Slides:



Advertisements
Similar presentations
© 2007 Lawrenceville Press Slide 1 Assignment Statement An assignment statement gives a value to a variable. Assignment can take several forms: x = 5;
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 3 Expressions.
1 CS150 Introduction to Computer Science 1 Arithmetic Operators.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
CS150 Introduction to Computer Science 1
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
Introduction to C Programming
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Introduction to Python and programming Michael Ernst UW CSE 190p Summer 2012.
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Copyright © 2003 Pearson Education, Inc. Slide 2-1 Problem Solving with Java™ Second Edition Elliot Koffman and Ursula Wolz Copyright © 2003 Pearson Education,
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
Chapter 02 (Part III) Introduction to C++ Programming.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
ITM © Port, KazmanVariables - 1 ITM 352 Expressions, Precedence, Working with Strings.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Computer Science 1620 boolean. Types so far: Integer char, short, int, long Floating Point float, double, long double String sequence of chars.
Introduction to Python and programming Ruth Anderson UW CSE 140 Winter
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Debugging Logic Errors CPS120 Introduction to Computer Science.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
1 09/27/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
Controlling Program Flow with Decision Structures.
 Most C programs perform calculations using the C arithmetic operators (Fig. 2.9).  Note the use of various special symbols not used in algebra.  The.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Chapter 02 (Part II) Introduction to C++ Programming.
A Sample Program #include using namespace std; int main(void) { cout
Fundamental Programming Fundamental Programming Data Processing and Expressions.
1 09/10/04CS150 Introduction to Computer Science 1 What Actions Do We Have Part 2.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
Precedence Operators Error Types
ARITHMETIC IN C Operators.
Chapter 2 Introduction to C++ Programming
Completing the Problem-Solving Process
Testing and Debugging.
Chapter 2 Assignment and Interactive Input
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Arithmetic operations & assignment statement
Variables, Expressions, and IO
Arithmetic Operator Operation Example + addition x + y
Lecture 3 Expressions Richard Gesick.
Introduction to Python and programming
Introduction to Python and programming
Introduction to C++ Programming
Programming Funamental slides
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Introduction to Python and programming
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Introduction to Python and programming
Presentation transcript:

 Monday, 9/9/02, Slide #1 CS106 Introduction to CS1 Monday, 9/9/02  QUESTIONS?? (Exercises, Lab #1, etc.)  Today:  More on float objects  C++ concept: Assignment statement  Operators and Precedence  Using the VCPP Debugger  Reading: Rest of Chapter 1  Exercises: p. 24 #12-14  New files/handouts: DebugMe.cpp

 Monday, 9/9/02, Slide #2 Some more about float objects  For now, all our program will use float objects  C++ also has int objects -- integers, or whole numbers.  What are the values of the C++ expressions:  10.0 / 4.0  10 / 4  Moral: To be sure a whole number constant is type float, use a decimal point

 Monday, 9/9/02, Slide #3 A New C++ operator: assignment  To convert feet to meters, a program could use the statement: meters =.3048 * feet; where meters and feet are float objects.  The symbol = is the assignment operator:  First the expression on the right is evaluated;  Then the computed value is assigned to the object named on the left.

 Monday, 9/9/02, Slide #4 Rules for using the assignment operator  Left side must be an object name  BAD: a + b = c;  Right side must be a valid expression whose type is compatible with left side (e.g., both numbers).  Any objects in right side must already have values (they’re “initialized”)  BAD: float x, y, z; x = y + z; //What’s x??

 Monday, 9/9/02, Slide #5 Using multiple operators in one expression  We have seen the following operators so far:  >> ><<+-* /=  We can also use parentheses ( )  If an expression uses more than one operator, C++ uses rules of precedence to decide the order of calculation:  Ex: cout << 2 * / 5; //What gets output?

 Monday, 9/9/02, Slide #6 Basic rules of operator precedence  C++ rules of precedence generally correspond to standard rules from algebra. From highest to lowest:  Parenthesized expressions  “Multiplicative” operations: * /  “Additive” operations: + -  Insertion, extraction: >  Assignment: =  Generally operators with equal precedence are evaluated left-to-right: x = 12 / 3 * 4

 Monday, 9/9/02, Slide #7 Using the VCPP Debugger, part 1  The VCPP Debugger is a tool which lets you trace the execution of a (compiled) program. Here are explanations of some of the buttons.  Run program up to cursor location  “Step over:” Execute line, don’t go inside function calls.  Stop debugging.  “Step into:” Execute line, do go inside function calls.  “Step out of: ”Execute rest of current function.  While it’s running the Debugger also displays two extra windows:  Variables Window: Shows values of current objects (variables)  Watch Window: Lets you type in objects or expressions that may not be displayed in the Variables Window.

 Monday, 9/9/02, Slide #8 Using the VCPP Debugger, part 2  To start the debugger:  Your program must be compiled.  Select Build-Start Debug-Step Into to start at beginning of main()  Or, first position cursor where you want it, and select Build-Start Debug-Run To Cursor.  The Debug Toolbar should appear -- if not, right-click on a gray border and then left-click on ‘Debug.’  For now use either:  Step over -- to execute one line at a time  Run to cursor -- to execute entire segments  Look for  The console window -- showing the progress of program output  The watch and variable windows

 Monday, 9/9/02, Slide #9 Example: DebugMe.cpp  Example based on program from text to convert feet to meters, with bugs added.  What are some good test data?  Which errors are syntax errors, semantic errors,run-time errors?