1.1 What is a programming language: How to think like computer experts (C ++ version)

zhaozj2021-02-16  36

Chapter 1

The Way of the Program of THE PROGRAM

Chapter 1 Programming Method

The goal of this book is to teach you to think like a computer scientist. I like the way computer scientists think because they combine some of the best features of Mathematics, Engineering, and Natural Science. Like mathematicians, computer scientists use formal languages ​​to denote ideas (specifically computations). Like engineers, they design things, assembling components into systems and evaluating tradeoffs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.

The purpose of this book is to teach you how to think about computer experts. I really like the way of thinking of computer experts because they combine some of the best features in mathematics, engineering and natural science. Like a mathematician, computer experts use formal language to express their minds (especially calculated). Like engineers, they designed things, assemble parts as systems, seek a balance in the candidate. Like scientists, they observe the behavior of complex systems, form a hypothesis, and test them.

The single most important skill for a computer scientist is problem-solving. By that I mean the ability to formulate problems, think creatively about solutions, and express a solution clearly and accurately. As it turns out, the process of learning to program is an Excellent Opportunity To Practice Problem-Solving Skills. That's whped chapter is caled "The Way of the program."

For a computer expert, the most important skill is the problem solving. I mean to express the ability to express issues, innovative thinking solutions, and clear and accurate expression of solutions. The process of learning programming is a great opportunity to solve skills in practice problems. This is why this chapter is called "programming method".

Of course, the other goal of this book is to prepare you for the Computer Science AP Exam. We may not take the most direct approach to that goal, though. For example, there are not many exercises in this book that are similar to the AP Questions. IF You Und The Concepts in this book, along with the details of programming in C , you will have 10 the Tools you need to do well on the example. Of course, the other goal of this book is to make You prepare a computer scientific ability test. However, we have no very straightforward ways to achieve this goal, for example, there is no too much practice with the ability to examine problems. Despite this, if you understand the content of this book, as well as C programming details, you will have all the foundations for achieving excellent results in the exam.

1.1 ???????? What is a programing logage?

1.1 What is a programming language

The programming language you will be learning is C , because that is the language the AP exam is based on, as of 1998. Before that, the exam used Pascal Both C and Pascal are high-level languages;. Other high-level languages ​​you Might Have Heard of Are Java, C and fortran.

The programming language you will learn is C , because the ability test begins in 1998 (before this is PASCAL), it is based on this language. C and pascal are both high-level languages; others you might hear, the language is Java, C, and Fortan.

As you might infer from the name "high-level language," there are also low-level languages, sometimes referred to as machine language or assembly language. Loosely-speaking, computers can only execute programs written in low-level languages. Thus, Programs Written in a high-level language have. This Translation takes Some Time, Which is a small disadvantage of high-level languages.

Maybe you will inform the name of "Advanced Language", there is also a low-level language, sometimes called machine language or assembly language. Frank, the computer can only perform programs written in low-level languages. Therefore, programs written in advanced languages ​​have to be converted before running. This conversion requires some time, which is a small shortcomings in advanced languages.

But the advantages are enormous First, it is much easier to program in a high-level language;. By "easier" I mean that the program takes less time to write, it's shorter and easier to read, and it's more likely to be correct . Secondly, high-level languages ​​are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can only run on one kind of computer, and have to be rewritten to run on another. However, Its advantage is huge. First, the use of advanced language programming is easier to program; "Easy" here, I mean is a shorter program spent, and the program written is more short, it is more likely to be correct. Second, advanced languages ​​can be portable, meaning that these programs can run over different types of computers through smaller modifications or without changes. Programs written in low-level languages ​​can only be run on a certain type of computer, but must be rewritten for use in other types of computers.

Due to these Advantages, Almost All Programs Are Written in High-Level Languages. Low-Level Languages ​​Are Only Used for a Few Special Applications.

Because of the above advantages, almost all procedures are written in advanced languages. Low-level languages ​​are used in some specific applications.

There are two ways to translate a program; interpreting or compiling An interpreter is a program that reads a high-level program and does what it says In effect, it translates the program line-by-line, alternately reading lines and carrying out.. Commands.

There are two ways to transform; explanation or compilation. The interpreter is a program that reads the advanced language program and performs the operations written by the program. In the effect, the transition to the program is alternately switched between the read line and the execution command.

A compiler is a program that reads a high-level program and translates it all at once, before executing any of the commands. Often you compile the program as a separate step, and then execute the compiled code later. In this case, the high -LEVEL Program Is Called The Source Code, and The Translated Program Is Called The Object Code or The Executable.

The compiler is a program that reads the advanced language program and then converts all before executing any of the commands. You often use the compiler as an independent step, and then execute the compiled code later. In this sense, the advanced language program is called source code, and the compiled program is called the target code or the executable program. As an example, suppose you write a program in C . You might use a text editor to write the program (a text editor is a simple word processor). When the program is finished, you might save it in a file named program.cpp WHERE "Program" is an arbitrary name you make up, and the suffix .cpp is a communication That INDICES That The File Contains C Source Code.

For example, suppose you write a program in a C language, you may use the text editor to write (text editor is a simple text processing software). When the program is written, saved as Program.cpp, "Program" in above is the common form of any file you give, the suffix .cpp is a common form of the C source program file.

Then, depending on what your programming environment is like, you might leave the text editor and run the compiler. The compiler would read your source code, translate it, and create a new file named program.o to contain the object code, or program .exe to contain the executable.

Then, leave the editor and run the compiler according to your programming environment. The compiler reads the program source code and converts, create a program.o file to save the target file, or Program.exe to save the executable code.

The next step is to run the program, which requires some kind of executor. The role of the executor is to load the program (copy it from disk into memory) and make the computer start executing the program.

The next step is to run the program, which requires some actuator. The actuator's role is to load programs (copy the program from the disk into memory) and start the computer to start the program.

Although this process may seem complicated, the good news is that in most programming environments (sometimes called development environments), these steps are automated for you. Usually you will only have to write a program and type a single command to compile and run it. On The Other Hand, IT IS Useful to Know What The Steps Are That Area If Something Goes Wrong You Can Figure Out What IT IS. Although this process can look complicated, good news is most In the programming environment (sometimes called development environments), these steps are automatic for you. Usually you only need to write a program, enter a directive to compile and run it. However, it is useful to know that these steps behind the scenes are useful. If something is wrong, you can point out where the fault is wrong.

转载请注明原文地址:https://www.9cbs.com/read-22736.html

New Post(0)