1. Trang chủ
  2. » Công Nghệ Thông Tin

John r hubbard programming with c++, 2nd ed (2000)

434 1,1K 3

Đ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

Thông tin cơ bản

Định dạng
Số trang 434
Dung lượng 4,46 MB

Nội dung

Đây là quyển sách tiếng anh về lĩnh vực công nghệ thông tin cho sinh viên và những ai có đam mê. Quyển sách này trình về lý thuyết ,phương pháp lập trình cho ngôn ngữ C và C++.

[...]... the programmer the power to write efficient, structured, object-oriented programs 1.1 GETTING STARTED To write and run C++ programs, you need to have a text editor and a C++ compiler installed on your computer A text editor is a software system that allows you to create and edit text files on your computer Programmers use text editors to write programs in a programming language such as C++ A compiler... left blank Dedicated to Anita H Hubbard Chapter 1 Programming is best regarded as the process of creating works of literature, which are meant to be read —Donald E Knuth Elementary C++ Programming A program is a sequence of instructions that can be executed by a computer Every program is written in some programming language C++ (pronounced “see-plus-plus”) is one of the most powerful programming languages... compiler already installed Use the Start key to look under Programs for Borland C++Builder, Metrowerks CodeWarrior, Microsoft Visual C++, or any other program with “C++” in its name If you have to buy your own C++ compiler, browse the Web for inexpensive versions of any of the compilers mentioned above These are usually referred to as IDEs (Integrated Development Environments) because they include their... the letter n There are several other characters formed this way, including the horizontal tab character '\t' and the alert character '\a' The backslash is also used to denote the two printing characters that could not otherwise be used within a string literal: the quote character \" and the backslash character itself \\ CHAP 1] ELEMENTARY C++ PROGRAMMING 5 Characters can be used in a program statement... Numeric overflow and division by zero are examples of run-time errors A compile-time error is an error that occurs when a program is being compiled Examples: syntax errors such as omitting a required semicolon, using an undeclared variable, using a keyword for the name of a variable Solutions to Problems 1.1 1.2 1.3 1.4 1.5 1.6 1.7 Four different statements, each subtracting 1 from the integer variable... Of course, everything stored in a computer, in RAM or on disk, is stored as 0s and 1s But all other types of data are formatted; i.e., interpreted as something such as a signed integer or a string of characters Þ Þ Þ Þ Þ Þ CHAP 2] FUNDAMENTAL TYPES 21 2.6 ARITHMETIC OPERATORS Computers were invented to perform numerical calculations Like most programming languages, C++ performs its numerical calculations... sign # is required to indicate that the word “include” is a preprocessor directive; the angle brackets < > are required to indicate that the word “iostream” (which stands for “input/output stream”) is the name of a Standard C++ Library file The expression is called a standard header The second line is also required in every C++ program It tells where the program begins The identifier main is... then incremented (or increased by any arithmetic operation), overflow will occur When integer overflow occurs the value of the offending variable will “wrap around” to negative values, producing erroneous results When floating-point overflow occurs, the value of the offending variable will be set to the constant inf representing infinity A run-time error is an error that occurs when a program is running... can be incremented and decremented with the ++ and -operators, respectively Each of these operators has two versions: a “pre” version and a “post” version The “pre” version performs the operation (either adding 1 or subtracting 1) on the object before the resulting value is used in its surrounding context The “post” version performs the operation after the object’s current value has been used EXAMPLE... int(c) = 33 integer value: endl; endl; endl; endl; Since character values are used for input and output, they appear in their character form instead of their integral form: the character 'A' is printed as the letter “A”, not as the integer 65 which is its internal representation The type cast operator int() is used here to reveal the corresponding integral value These are the characters’ ASCII codes . the print version of this title: ISBN 0-0 7-1 3534 6-1 . All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every. licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error

Ngày đăng: 19/03/2014, 14:10

TỪ KHÓA LIÊN QUAN