中国高校课件下载中心 》 教学资源 》 大学文库

《C++程序设计》(英文版) Chapter 3 Topics

文档信息
资源类别:文库
文档格式:PPT
文档页数:89
文件大小:3.37MB
团购合买:点击进入团购
内容简介
Chapter 3 Topics Constants of Type int and float Evaluating Arithmetic Expressions Declaration for Numeric Types s Implicit Type Coercion and Explicit Type Conversion
刷新页面文档预览

Programming in C++ Numeric Types, Expressions, and Output Dale/weems/Headington

1 Numeric Types, Expressions, and Output

Programming in c++ Chapter 3 Topics 8 Constants of Type int and float Evaluating Arithmetic Expressions e Declaration for Numeric Types 8 Implicit Type Coercion and Explicit Type Conversion Calling a Value-Returning Function s Using Function Arguments s Using C++ Library Functions in Expressions Calling a Void Function % C++ Manipulators to Format Output s String Operations length, size, find, substr

2 Chapter 3 Topics v Constants of Type int and float v Evaluating Arithmetic Expressions v Declaration for Numeric Types v Implicit Type Coercion and Explicit Type Conversion v Calling a Value-Returning Function v Using Function Arguments v Using C++ Library Functions in Expressions v Calling a Void Function v C++ Manipulators to Format Output v String Operations length, size, find, substr

Programming in c++ C++ Data Types sImple structured integral enum floating array struct union class har short int long bool float double long double address pointer reference

3 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long double

Programming in c++ C++ Simple Data Types simple types integral floating char short int long bool enum float double long double unsigned

4 C++ Simple Data Types simple types integral floating char short int long bool enum float double long double unsigned

Programming in c++ Standard Data Types in C++ sIntegral Types represent whole numbers and their negatives declared as int, short, or long & Floating Types represent real numbers with a decimal point declared as float, or double &Character Type represents single characters declared as char

5 Standard Data Types in C++ vIntegral Types • represent whole numbers and their negatives • declared as int, short, or long vFloating Types • represent real numbers with a decimal point • declared as float, or double vCharacter Type • represents single characters • declared as char

Programming in c++ Samples of C++ Data Values int sample values 4578 4578 0 float sample values 95274 95 265 9521E-3 95E-1 95213E2 char sample values B d′

6 Samples of C++ Data Values int sample values 4578 -4578 0 float sample values 95.274 95. .265 9521E-3 -95E-1 95.213E2 char sample values ‘B’ ‘d’ ‘4’ ‘?’ ‘*’

Programming in c++ Integral Types >The data types char, short, int, and long are intended to represent different sizes of integers > The sizes are machine dependent >For one particular machine, we might picture the sizes this way char memory cell short memory cel int memory cell long memory cell 7

7 Integral Types ØThe data types char, short, int, and long are intended to represent different sizes of integers. ØThe sizes are machine dependent. ØFor one particular machine, we might picture the sizes this way. char memory cell short memory cell int memory cell long memory cell

Programming in c++ Integral Types( Cont) >We can also explicitly add the reserved word unsigned to the data type name unsigned int )The unsigned integer value is assumed to be only positive or zero

8 Integral Types(Cont.) ØWe can also explicitly add the reserved word unsigned to the data type name: unsigned int ØThe unsigned integer value is assumed to be only positive or zero

Programming in c++ Scientific Notation 2.7E4 means 2.7x 104= 2.7000 27000.0 2.7E.4 means 27x 10-4= 00027 0.00027

9 Scientific Notation 2.7E4 means 2.7 x 10 4 = 2.7000 = 27000.0 2.7E-4 means 2.7 x 10 - 4 = 0002.7 = 0.00027

Programming in c++ More About Floating Point Values s floating point numbers have an integer part and a fractional part, with a decimal point in between Either the integer part or the fractional part, but not both, may be missing 今 EXAMPLES 18.4 500. 8 127.358 o alternatively, floating point values can have an exponent, as in scientific notation--the number preceding the letter E doesn't need to include a decimal point EXAMPLES 1.84E1 5E2 8E-1 -.127358E3 10

10 More About Floating Point Values v floating point numbers have an integer part and a fractional part, with a decimal point in between. Either the integer part or the fractional part, but not both, may be missing v EXAMPLES 18.4 500. .8 -127.358 v alternatively, floating point values can have an exponent, as in scientific notation--the number preceding the letter E doesn’t need to include a decimal point EXAMPLES 1.84E1 5E2 8E-1 -.127358E3

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档