Download > Manual Download > Pascal basic tutorial Pascal essential basic tutorial for getting started CHM version
No matter what you do, there must be certain methods and steps. Computer programming is more rigorous, standardized, and feasible than transaction processing in daily life. In order for the computer to effectively solve certain problems, the processing steps must be arranged and a "sequence" composed of computer language is used to allow the computer to automatically recognize and execute this "sequence" composed of computer language to complete the predetermined task. Arrange the steps to deal with the problem and use computer language to form a sequence, which is often called writing a program. In the Pascal language, each statement is executed by the computer to complete the corresponding operation. Writing a Pascal program is to use the functions of Pascal statements to implement and achieve predetermined processing requirements. "A journey of a thousand miles begins with a single step." We start with simple programs and gradually understand and master how to write programs.
Section 1 Pascal Program Structure and Basic Statements
Before you systematically learn the Pascal language, let’s temporarily bypass the tedious details of grammatical rules. Through the following simple examples, you can quickly master the Pascal program. The basic composition and usage of basic statements allow beginners to directly imitate and learn to write simple programs.
[Example 1.1] Program to display "Hello World!" on the screen.
Pascal program:
Program ex11;
Begin
Writeln(‘Hello World!’);
ReadLn;
End.
With this simple sample program, I hope everyone can have a good start in programming learning. Writeln in the program is an output statement, which can instruct the computer to output corresponding content on the screen. Following the Writeln statement is a pair of parentheses, and the part enclosed in single quotes will be displayed intact.
[Example 1.2] It is known that the selling price of a bicycle is 300 yuan. Please program to calculate the total price of a bicycle?
Solution: If the total selling price is represented by m, then this problem can be divided into the following steps:
= 1 \* GB3 ①Input the number of bicycles a from the keyboard;
= 2 \* GB3 ② Use the formula m=300*a to calculate the total selling price;
= 3 \* GB3 ③ Output the calculation results.
Pascal program:
Program Ex12; a=’);
ReadLn(a); {Calculate total selling price}
Writeln(‘M=’, m) ; Pascal programs consist of three parts:
(1) The program header
begins with the reserved word Program, followed by a program name (such as: Exl1); its format is:
Program program name;
The program name is determined by the user Pick it yourself. Its first character must be an English letter, and subsequent characters can only be composed of letters or numbers and underscores. Operators, punctuation characters, and spaces cannot appear in the program name.
All resources on this website are contributed and published by netizens, or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this website are for learning and reference only. Please do not use them for commercial purposes, otherwise you will be responsible for all consequences incurred! If there is any infringement, please contact us to delete and remove it. Contact information: admin@php.cn