ผลต่างระหว่างรุ่นของ "ภาษาปาสกาล"

จากวิกิพีเดีย สารานุกรมเสรี
เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
Auto 955 (คุย | ส่วนร่วม)
ไม่มีความย่อการแก้ไข
Auto 955 (คุย | ส่วนร่วม)
ไม่มีความย่อการแก้ไข
บรรทัด 6: บรรทัด 6:
writeln('text');
writeln('text');
end.
end.
==หลักการเขียนโปรแกแกรมภาษา ปาสคาล(PASCAL==
==หลักการเขียนโปรแกแกรมภาษา ปาสคาล(PASCAL)==
DIM ใช้การนิยามตัวแปร เช่นนิยามตัวแปร A,B,C,D
DIM ใช้การนิยามตัวแปร เช่นนิยามตัวแปร A,B,C,D



รุ่นแก้ไขเมื่อ 17:05, 20 กันยายน 2548

ภาษาปาสกาล (Pascal programming language) เป็นภาษาโปรแกรม ที่ใช้กันอย่างกว้างขวาง โดยเฉพาะในวงการศึกษา คิดค้นขึ้นโดย นักวิทยาศาสตร์คอมพิวเตอร์ ชาวสวิตเซอร์แลนด์ ชื่อ นิเคลาส์ แวร์ท ในปี ค.ศ. 1970 เพื่อช่วยในการเรียนการสอนการเขียนโปรแกรมโครงสร้าง (structured programming). ภาษาปาสกาลนั้นพัฒนาขึ้นมาจาก ภาษาอัลกอล (Algol), และชื่อปาสกาลนั้น ตั้งเพื่อเป็นเกียรติแก่ แบลส ปาสกาล (en:Blaise Pascal). นอกเหนือจากภาษาปาสกาลแล้ว, แวร์ทได้พัฒนา ภาษาโมดูลาทู (Modula-2) และ โอบีรอน (Oberon) ซึ่งมีโครงสร้างคล้ายกับภาษาปาสกาล แต่มีความสามารถรองรับ การเขียนโปรแกรมเชิงวัตถุ (object-oriented programming).

โครงสร้าง อย่างง่าย

program PascalProgram1(output);
begin
 writeln('text');
end.

หลักการเขียนโปรแกแกรมภาษา ปาสคาล(PASCAL)

DIM ใช้การนิยามตัวแปร เช่นนิยามตัวแปร A,B,C,D

โปรแกรมการหาระยะห่างระหว่างจุด

DIM A as integer , b as integer ,C as integer ,D as integer A = txt1.text B = txt2.text C = txt3.text D = txt4.text result = ((A-B)^2 + (C-D)^2)^0.5 result = cal.caption

ตัวอย่างการใช้คำสั่ง DIM ในโปรแกรม ไฮโล

Option Explicit

Private Sub cmdExit_Click() End End Sub

Private Sub cmdRollDice_Click() Dim result As Integer Dim total As Integer

imgCoin.Visible = False Randomize result = Int((6 * Rnd) + 1) lblDice1.Caption = result

result = Int((6 * Rnd) + 1) lblDice2.Caption = result

result = Int((6 * Rnd) + 1) lblDice3.Caption = result

total = CInt(lblDice1.Caption) + CInt(lblDice2.Caption) + CInt(lblDice3.Caption) lblTotal.Caption = total

Select Case total Case Is > 11 lblResult.Caption = "HIGH" If optHigh.Value Then imgCoin.Visible = True End If Case Is < 11 lblResult.Caption = "LOW" If optLow.Value Then imgCoin.Visible = True End If Case 11 lblResult.Caption = "HI-LO" If optHiLo.Value Then imgCoin.Visible = True End If End Select End Sub


Private Sub Form_Load()

End Sub

Private Sub imgCoin_Click()

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub lblDice1_Click()

End Sub

Private Sub lblDice2_Click()

End Sub

Private Sub lblDice3_Click()

End Sub

Private Sub lblResult_Click()

End Sub

Private Sub lblTotal_Click()

End Sub

Private Sub optHigh_Click()

End Sub

Private Sub optHiLo_Click()

End Sub

Private Sub optLow_Click()

End Sub