{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

numerical - Programming C Numerical Data Input/Output...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ Numerical Data Input/Output Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Fundamentals I:C++ Numerical Data, Input/Output /Slide 2 Rules for Division C++ treats integers differently from decimal numbers. 100 is an int type. 100.0 , 100.0000, and 100. are double type. The general rule for division of int and double types is: double / double -> double (normal) double / int -> double (normal) int / double -> double (normal) int / int -> int (note: the decimal part is discarded)
Background image of page 2
Fundamentals I:C++ Numerical Data, Input/Output /Slide 3 Rules for Division Examples: 220. / 100.0 double / double -> double result is 2.2 220. / 100 double / int -> double result is 2.2 220 / 100.0 int / double -> double result is 2.2 220 / 100 int / int -> int result is 2 Summary: division is normal unless both the numerator and denominator are int , then the result is an int (the decimal part is discarded).
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Fundamentals I:C++ Numerical Data, Input/Output /Slide 4 Assignment Conversions A decimal number assigned to an int type variable is truncated. An integer assigned to a double type variable is converted to a decimal number. Example 1: double yy = 2.7; int i = 15; int j = 10; i = yy; // i is now 2 yy = j; // yy is now 10.0
Background image of page 4
Fundamentals I:C++ Numerical Data, Input/Output /Slide 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}