1 / 12

Sha Tin Methodist College F.4 Computer Studies

Sha Tin Methodist College F.4 Computer Studies. Pascal Programming. 10. ASCII Table and String Comparison. Converting a character to ASCII code: e.g. ord(“char type”); Converting an ASCII code to character: e.g. chr(“integer type”); String Comparison. 11. String Manipulation.

jalia
Download Presentation

Sha Tin Methodist College F.4 Computer Studies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sha Tin Methodist CollegeF.4 Computer Studies Pascal Programming

  2. 10. ASCII Table and String Comparison • Converting a character to ASCII code: e.g. ord(“char type”); • Converting an ASCII code to character: e.g. chr(“integer type”); • String Comparison

  3. 11. String Manipulation • The length of the string: e.g. length(“string type”); • Selecting a character from a string: e.g. a[n]

  4. 11. String Manipulation • Selecting part of string: e.g. copy(string1, integer1,integer2); • String concatenation: e.g. concat(string1, string2); or “+”

  5. 11. String Manipulation • Convert a number into a string: e.g. str(“integer type”, “string type”); • Convert a string into numeric form: e.g. val(string1, number1, error_postion); • <eoln>: end of line (“Enter”)

  6. 12. Procedures • Procedure is a group of statements which can be called from different parts in a program. • Global and local variables • Parameter passing

  7. 13. File Handling • Steps in creating a new file: 1.Declare a file variable: e.g. var phone: text; 2.Assign the file variable with a file name: e.g. assign(phone, ‘tele.txt’);

  8. 13. File Handling 3.Open the file for output: e.g. rewrite(phone); 4.Write to the file: e.g. writeln(phone, variable1, variable2…); 5.Close the file: e.g. close(phone);

  9. 13. File Handling • Steps in reading a new file:Same as steps in creating a new file except step 3 and 4: reset(phone); readln(phone, variable1, variable2…); • End of file consideration: <eof>

  10. 14. Two dimensional array • Declaration of 2D array: e.g. var A: array[1..3, 1..4] of integer; • Use 2 for loops

  11. 15. Sorting • Bubble Sort

  12. 15. Sorting • Procedure “Swap” • Use 2 for loops in the main program • Merge SortThe Algorithm of the sorting

More Related