1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Chap2 slides

38 1 0

Đ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 38
Dung lượng 134,5 KB

Nội dung

Chap2 slides [Compatibility Mode] Programming Fundamentals 1 Chapter 2 BASIC ELEMENTS IN C++ Programming Fundamentals 2 Chapter 2 n Program structures n Data types and operators n Variables and declar[.]

Chapter BASIC ELEMENTS IN C++ Programming Fundamentals Chapter n n n n n Program structures Data types and operators Variables and declaration statements Integer quantifiers Some sample programs Programming Fundamentals Modular programs n A large program should be organized as several interrelated segments: The segments are called modules n A program which consists of such modules is called a modular program n In C++, modules can be classes or functions n A function is a program segment that transforms the data it receives into a finished result Programming Fundamentals Function n n Each function must have a name Names or identifiers in C++ can made up of any combination of letters, digits, or underscores selected according to the following rules: - Identifiers must begin within an uppercase or lowercase ASCII letter or an underscore (_) - You can use digits in an identifier, but not as the first character You are not allowed to use special characters such as $, &, * or % - Reserved words cannot be used for variable names n Example: DegToRad FindMax1 intersect _density Programming Fundamentals addNums slope The main() function n The main() function is a special function that runs automatically when a program first executes n All C++ programs must include one main() function All other functions in a C++ program are executed from the main() n The first line of the function, in this case int main() is called a function header line n The function header line contains three pieces of information: What type of data, if any, is returned from the function 2.The name of the function What type of data, if any, is sent into the function Programming Fundamentals The main() function (cont.) int main() { program statements in here return } The line return 0; is included at the end of every main function C++ keyword return is one of several means we will use to exit a function When the return statement is used at the end of main(), the value indicates that the program has terminates successfully Programming Fundamentals The cout Object n The cout object is an output object that sends data given to it to the standard output display device n To send a message to the cout object, you use the following pattern: cout

Ngày đăng: 11/04/2023, 16:03

TÀI LIỆU CÙNG NGƯỜI DÙNG

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

TÀI LIỆU LIÊN QUAN