Chapter 3 The New Math. C++ Data Types simple integral charshort intlong bool floating float double Long double enum address pointer reference structured.

Slides:



Advertisements
Similar presentations
Neal Stublen C# Data Types Built-in Types  Integer Types byte, sbyte, short, ushort, int, uint, long, ulong  Floating Point Types.
Advertisements

Dale/Weems/Headington
More Review, with Some New Chapter 3. Review C++ simple data types – Integral and float – Arithmetic operators Expressions and expression evaluation –
Numeric Types, Expressions, and Output ROBERT REAVES.
Dale/Weems/Headington
1 CSE1301 Computer Programming Lecture 5 C Primitives 2.
1 Lecture 6 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
1 Chapter 3 Arithmetic Expressions. 2 Chapter 3 Topics l Overview of Java Data Types l Numeric Data Types l Declarations for Numeric Expressions l Simple.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Chapter 4 Numeric Types.
Data types and variables
1 Chapter 3 Topics Constants of Type int and float l Evaluating Arithmetic Expressions l Implicit Type Coercion and Explicit Type Conversion l Calling.
Expressions An expression is a sequence of operands and operators that reduces to a single value expression operator operand An operator is a language-specific.
Chapter 2 Data Types, Declarations, and Displays
1 Lecture 7 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Data Types, Expressions and Functions (part I)
Performing Computations C provides operators that can be applied to calculate expressions: example: tax is 8.5% of the total sale expression: tax =
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
Expressions and Interactivity Chapter 3. 2 The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Often.
***** SWTJC STEM ***** Chapter 2-3 cg 29 Java Operators Recall Java’s programming components: Packages - Collection of classes (Programs) Classes - Collections.
Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Object-Oriented Programming Using C++ Third Edition Chapter 2 Evaluating C++ Expressions.
1 Numeric Types, Expressions, and Output. 2 Chapter 3 Topics  Constants of Type int and float  Evaluating Arithmetic Expressions  Declaration for Numeric.
Numeric Types, Expressions, and Output 1. Chapter 3 Topics Constants of Type int and float Evaluating Arithmetic Expressions Implicit Type Coercion and.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems.
1 Chapter 3 Numeric Types, Expressions, and Output CS185/09 - Introduction to Programming Caldwell College.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Numeric Types, Expressions, and Output ROBERT REAVES.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 2: Using Data.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Java Programming: From Problem Analysis to Program Design, 5e Chapter 2 Basic Elements of Java.
1 Chapter 3 Numeric Types, Expressions, and Output.
Chapter 3 Arithmetic Expressions, Function Calls, and Output
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
1 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Data Types Declarations Expressions Data storage C++ Basics.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
Java Programming, Second Edition Chapter Two Using Data Within a Program.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
C++ Data Types Check sample values of? ‘4’
Chapter 3 Numeric Types, Expressions, and Output.
1 Chapter 15-1 Pointers, Dynamic Data, and Reference Types Dale/Weems.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
1 A Simple “Hello World” Example #include // input-output library using namespace std; int main() // function main { cout
1 Lecture Three I/O Formatting and Arithmetic Dr. Sherif Mohamed Tawfik.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
CSCI 125 & 161 / ENGR 144 Lecture 6 Martin van Bommel.
Chapter 3 Numeric Types, Expressions, and Output
Java Programming: From Problem Analysis to Program Design, 4e
Conversions of the type of the value of an expression
Chapter 7 Additional Control Structures
Formatting the Output The C++ standard library supplies many manipulators: endl, setw, fixed, showpoint, setprecesion. If we want to use endl, fixed, or.
Primitive Types and Expressions
Module 2 Variables, Data Types and Arithmetic
Chapter 3 The New Math.
Presentation transcript:

Chapter 3 The New Math

C++ Data Types simple integral charshort intlong bool floating float double Long double enum address pointer reference structured array struct union class

Numeric Data Types  char 1 byte  short 2 bytes  int 4 bytes  long 4 bytes

More Numeric Data Types  float 4 bytes  double 8 bytes  long double 8 bytes

Declarations  Constant Examples const floatPI = ; const floatE = ; const intMAX_SCORE = 100;  Variable Examples int studentCount; chargrade; floataverageGrade;

Simple Arithmetic Expressions  Expressions are made up of constants, variables and operators  Examples alpha + 2 rate – – alpha rate alpha * num

Arithmetic Operators  - Unary Minus  + Unary Plus  - Subtraction  + Addition  * Multiplication  / Division  % Modulus

 Expression – * / / / / / % % % % % 2.3  Value error

Oh yeah, don’t forget  Increment ++  Decrement --

Let’s Get Tricky  Precedence Rules Highest: Unary + Unary – Middle: * / % Lowest: + - See Appendix B for complete list

Type Coercion and Type Casting  Type Coercion The implicit (automatic) conversion of a value from one data type to another  Type Casting The explicit conversion of a value from one data type to another

Examples  float someFloat = 3.4 / 2;  int someInt = 3.4 / 2;  someFloat = 3 / 4;  someInt = 3.4 / 2.2;

Casting  someFloat = double (3) / double (4);  someFloat = (double) 3 / (double) 4;

Function Calls  Example int someInt = Cube(27);  Function Call (Function Invocation) The mechanism that transfer control to the function  Argument List (Parameter List) A mechanism by which functions communicate with each other

Formatting Output  setw() Tells how many characters the next item outputted should have  fixed Force all subsequent floating-point output to appear in decimal notation  showpoint Force decimal points in all subsequent floating- point output; even whole numbers  setprecision() Tells how many decimal places all subsequent floating-point output should have

String Functions  length() or size()  find()  substr()