Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
This chapter introduces the C++ language and gives enough detail to allow you to handle simple programs involving expression, assignments, and console input/output (I/O). The details of assignment and expressions are similar to those of most other high-level languages. Every language has its own console I/O syntax, so if you are not familiar with C++, that may look new and different to you. | C Basics 1.1 INTRODUCTION TO C 2 Origins of the C Language 2 C and Object-Oriented Programming 3 The Character of C 3 C Terminology 4 A Sample C Program 4 1.2 VARIABLES EXPRESSIONS AND ASSIGNMENT STATEMENTS 6 Identifiers 6 Variables 8 Assignment Statements 10 Pitfall Uninitialized Variables 12 Tip Use Meaningful Names 13 More Assignment Statements 13 Assignment Compatibility 14 Literals 15 Escape Sequences 17 Naming Constants 17 Arithmetic Operators and Expressions 19 Integer and Floating-Point Division 21 Pitfall Division with Whole Numbers 22 Type Casting 23 Increment and Decrement Operators 25 Pitfall Order of Evaluation 27 1.3 CONSOLE INPUT OUTPUT 28 Output Using cout 28 New Lines in Output 29 Tip End Each Program with n or endl 30 Formatting for Numbers with a Decimal Point 30 Output with cerr 32 Input Using cin 32 Tip Line Breaks in I O 34 1.4 PROGRAM STYLE 35 Comments 35 1.5 LIBRARIES AND NAMESPACES 36 Libraries and include Directives 36 Namespaces 37 Pitfall Problems with Library Names 38 CHAPTER SUMMARY 38 ANSWERS TO SELF-TEST EXERCISES 39 PROGRAMMING PROJECTS 41 C Basics The Analytical Engine has no pretensions whateverto originate anything. It can do whatever we know how to order it to perform. It can follow analysis but it has no power of anticipating any analytical relations or truths. Its province is to assist us in making available what we are already acquainted with. Ada Augusta Countess of Lovelace Introduction This chapter introduces the C language and gives enough detail to allow you to handle simple programs involving expression assignments and console input output I O . The details of assignment and expressions are similar to those of most other high-level languages. Every language has its own console I O syntax so if you are not familiar with C that may look new and different to you. 1.11 Introduction to C Language is the only instrument of science. Samuel Johnson This section gives an overview of the C programming language. origins of the C .