Lecture Programming principles and practice using C++: Chapter 4 - Bjarne Stroustrup

Chapter 4 present the basics of computation. In particular, this chapter discuss expressions, how to iterate over a series of values (“iteration”), and select between two alternative actions (“selection”). This chapter also show how a particular sub-computation can be named and specified separately as a function. | Chapter 4 Computation Bjarne Stroustrup Abstract Today, I’ll present the basics of computation. In particular, we’ll discuss expressions, how to iterate over a series of values (“iteration”), and select between two alternative actions (“selection”). I’ll also show how a particular sub-computation can be named and specified separately as a function. To be able to perform more realistic computations, I will introduce the vector type to hold sequences of values. Selection, Iteration, Function, Vector Stroustrup/Programming/2015 Overview Computation What is computable? How best to compute it? Abstractions, algorithms, heuristics, data structures Language constructs and ideas Sequential order of execution Expressions and Statements Selection Iteration Functions Vectors Stroustrup/Programming/2015 You already know most of this Note: You know how to do arithmetic d = a+b*c You know how to select “if this is true, do that; otherwise do . | Chapter 4 Computation Bjarne Stroustrup Abstract Today, I’ll present the basics of computation. In particular, we’ll discuss expressions, how to iterate over a series of values (“iteration”), and select between two alternative actions (“selection”). I’ll also show how a particular sub-computation can be named and specified separately as a function. To be able to perform more realistic computations, I will introduce the vector type to hold sequences of values. Selection, Iteration, Function, Vector Stroustrup/Programming/2015 Overview Computation What is computable? How best to compute it? Abstractions, algorithms, heuristics, data structures Language constructs and ideas Sequential order of execution Expressions and Statements Selection Iteration Functions Vectors Stroustrup/Programming/2015 You already know most of this Note: You know how to do arithmetic d = a+b*c You know how to select “if this is true, do that; otherwise do something else ” You know how to “iterate” “do this until you are finished” “do that 100 times” You know how to do functions “go ask Joe and bring back the answer” “hey Joe, calculate this for me and send me the answer” What I will show you today is mostly just vocabulary and syntax for what you already know Stroustrup/Programming/2015 Computation Input: from keyboard, files, other input devices, other programs, other parts of a program Computation – what our program will do with the input to produce the output. Output: to screen, files, other output devices, other programs, other parts of a program (input) data (output) data data Code, often messy, often a lot of code Stroustrup/Programming/2015 Computation Our job is to express computations Correctly Simply Efficiently One tool is called Divide and Conquer to break up big computations into many little ones Another tool is Abstraction Provide a higher-level concept that hides detail Organization of data is often the key

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
20    540    2    28-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.