C++ lecture 8

13 5 0
C++ lecture 8

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

C++ Programming Lecture Input/Output Manipulations The Hashemite University Computer Engineering Department (Adapted from the textbook slides) Outline       Introduction Floating-Point Numbers; Scientific Notation Floating-Point Precision Field Width Trailing Zeros and Decimal Points Padding The Hashemite University Input/Output Manipulations I    C++ provides various stream manipulators that perform formatting tasks Till now we have dealt with screen output using cout So, all these manipulators will format the text that appears on the screen Examples:     Setting the precision of the displayed floating point numbers Setting the field width Showing trailing zeros and decimal point in floating point numbers Filling field with specific characters The Hashemite University Input/Output Manipulations II   All the previous tasks or functions are provided via the iomanip library (short for input/output manipulation) So, when you want to use any of these functions you must include this library in your code #include using namespace std; The Hashemite University Input/Output Manipulations III  These functions or operators are classified into:  Sticky operators:   Applied to all subsequent cout statements that come after calling the specified function Non-sticky operators:  Applied only to the first cout statement that comes after calling the specified function The Hashemite University Floating-Point Numbers; Scientific Notation (scientific, fixed)  scientific  forces output of a floating point number in scientific notation:  1.946000e+009 Only one digit in the integer part of the floating point number and n digits after the floating point (depends on the precision value and by default its 6) and put the suitable power after the e exponent  E.g.: cout

Ngày đăng: 12/10/2021, 21:08

Mục lục

    C++ Programming Lecture 8 Input/Output Manipulations

    Input/Output Manipulations I

    Input/Output Manipulations II

    Input/Output Manipulations III

    Floating-Point Numbers; Scientific Notation (scientific, fixed)

    Trailing Zeros and Decimal Points (showpoint)

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan