numerical

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

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

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

View Full Document

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.

Unformatted text preview: C++ Numerical Data Input/Output Programming 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). 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....
View Full Document

{[ snackBarMessage ]}

### Page1 / 14

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

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online