{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

numerical

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

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

C++ Numerical Data Input/Output Programming

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

View Full Document
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)
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).

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

View Full Document
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
Fundamentals I:C++ Numerical Data, Input/Output /Slide 5

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}