Introduction. In today’s session… What is programming? Why should I learn programming? Course Outline Introduction to Programming Language Introduction.

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

Pascal Syntax. What you have learnt so far writeln() and write(); readln() and read(); variables (integers, strings, character) manipulation of variables.
Single Variable and a Lot of Variables The declaration int k; float f; reserve one single integer variable called k and one single floating point variable.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Chapter 8 Arrays and Strings
JavaScript, Third Edition
1 Lecture 3  Lexical elements  Some operators:  /, %, =, +=, ++, --  precedence and associativity  #define  Readings: Chapter 2 Section 1 to 10.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Computer Science 101 Introduction to Programming.
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Computer Science 101 Introduction to Programming.
C Tokens Identifiers Keywords Constants Operators Special symbols.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 8 Arrays and Strings
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Computer Science 101 Introduction to Programming.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
The basics of the array data structure. Storing information Computer programs (and humans) cannot operate without information. Example: The array data.
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
Introduction to Pascal The Basics of Program writing.
Introduction to PHP Advanced Database System Lab no.1.
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
Programming, an introduction to Pascal
1 STRINGS String data type Basic operations on strings String functions String procedures.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Pointers *, &, array similarities, functions, sizeof.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
CHAPTER 6 ARRAYS IN C++ 2 nd Semester King Saud University College of Applied studies and Community Service CSC 1101 By: Fatimah Alakeel Edited.
C++ Programming Lecture 13 Functions – Part V The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
CPS120: Introduction to Computer Science Variables and Constants.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Chapter 8 Characters and Strings. Objectives In this chapter, you will learn: –To be able to use the functions of the character handling library ( ctype).
Basic Java Syntax Comments Basic data types Operators and assignment.
Computer Programming for Engineers
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Copyright © Curt Hill Simple I/O Input and Output using the System and Scanner Objects.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 9: Arrays; Revision Session.
Chapter 1: Introduction to Computers and Programming.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
C++ Programming Lecture 13 Functions – Part V By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Topic: Python’s building blocks -> Variables, Values, and Types
The CONST definition CONST Pi = , City = ‘New York’;
Topic: Python’s building blocks -> Variables, Values, and Types
Documentation Need to have documentation in all programs
Computing Fundamentals
ITEC113 Algorithms and Programming Techniques
Revision Lecture
Lecture2.
Chapter 10 Programming Fundamentals with JavaScript
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Introduction to C++ Programming
PHP.
COMPUTER PROGRAMMING SKILLS
PHP an introduction.
Comparing Python and Java
Getting Started With Coding
Presentation transcript:

Introduction

In today’s session… What is programming? Why should I learn programming? Course Outline Introduction to Programming Language Introduction to Pascal ‘Hello world!’ ‘Hello, !’ Variables

What is programming? Process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs (From Wikipedia) To create a program (software) for usage of a particular sort, e.g. word processor (e.g. Microsoft Word, OpenOffice.org Writer) for word processing (duh)

Why should I learn programming? Logic skills – very useful in Maths/Physics/Chemistry/… Understand more about computer / information systems Learn algorithms Learn how to type – fast! Represent the school in HKOI/CCC

Course Outline Introduction3/5 Pascal Syntax – I6/5 Pascal Syntax – II10/5 Pascal Syntax – III (depends on schedule)13/5 Algorithms – I17/5 Algorithms – II (depends on schedule)20/5 HTML24/5 CSS27/5 PHP31/5

Introduction to Programming Language Derived from human language Syntax – grammatical rules Symbol-like Lots: Pascal, A+, A++, B, C, C--, C++, C#, D, D#, E, F, F#, J, J++, J#, K, L, L++, M, Q, R, R++, S, T, X++, Y, Z, VB, ActionScript, PHP, FORTRAN, Java, Javascript, Python, etc. For different purposes and with different syntax / ideology behind programming

Introduction to Pascal ‘Educational’ Syntax are human-like, easy to understand Important in programming Have practical use despite criticisms

Hello, world! Classic approach to any programming language Objective: Print ‘Hello, world!’ Code: program hello; var a : integer; begin writeln(‘Hello, world!’); end.

Hello, world! Analysis program hello; ‘;’ : to separate different statements ‘program’ : a special keyword, to specify the name of the program ‘hello’: the name of the program * this statement can be ignored totally. * note any ‘name’ cannot be special keywords or start with numbers. E.g. program 3x; or program program; is not valid, but program _3x; or program _program; is valid.

Hello, world! Analysis (cont.) var a : integer; ‘var’ : a special keyword, to notify the following statements are declaration of variables ‘a’: the name of the variable ‘:’: declare ‘a’ is which type of variable ‘integer’: a type of variable, which is integers (with range ) * this statement can be ignored totally since this program has no use of variables * note program hello; var a : integer; is valid. * note var a, b, c : integer; is valid.

Hello, world! Analysis begin writeln(‘Hello, world!’); end. ‘begin’ : to specify the beginning of the program ‘writeln’ : a function, to write the value then with a line break * Try this out: writeln(‘Hello’); write(‘Hello’); writeln(‘Hello’); (What is the difference between writeln() and write() ?) writeln; is valid (what does this do?) ‘’’: to specify that the worlds ‘Hello, world!’ is a string, i.e. a series of characters, but not a variable. * writeln(‘Hello’); and writeln(Hello); ‘end.’: to specify the end of the program

Hello, ! Objective: Print ‘Hello,’, then the name of the user who has inputted his/her name in the first place. Code: program hello; var name : string; begin write(‘Please input your name: ’); readln(name); writeln(‘Hello, ‘, name, ‘!’); end.

Hello, ! Analysis var name:string; ‘string’ : a type of variable, which is the compilation of characters ‘name’: the name of variable of string * Variables come in different kinds, e.g. for integers, we have integer, longint, int64; for characters, we have char; for string, we have string, ANSIstring. * Each type of variables have different operations. * Variable can be assigned by ‘:=‘. E.g. name := ‘This is my name’ or a := 3; Note that ‘’ is added to state that the values inside is a string! a := a + 1 is possible!

Hello, ! Analysis readln(name); ‘readln’ : to request input of variable to the user ‘name’: the name of variable of string * Try read(name); instead of readln(name);, Or guess what’s the differences between readln and read.

Hello, ! Analysis writeln(‘Hello, ‘,name,’!’); ‘,’ is used to separate strings and values in the variable ‘name’ * writeln(‘H’,’e’,’l’,’l’,’o’,’,’,’ ‘,’); is equivalent to writeln(‘Hello,’);

Variables Integral types (0, 1, 2, 3, …) Shortint ( ) Byte (0..255) Integer ( ) Word0 ( ) Longint( ) Floating point types (0.1, 0.23, etc.) Real Double

Variables Operations of Integral / Floating point types ‘+’, e.g. c := a+b; ‘-’ e.g. c := a-b; ‘*’ e.g. c := a*b; ‘/’ e.g. c := a/b; ‘div’ e.g. c := a div b; ‘mod’ e.g. c := a mod b; ‘()’ e.g. c := (a + b)*a;

Variables Non-numerical Char (characters, e.g. ‘a’, ‘A’, ‘!’) String (an array of characters, usually max. at 255) Array (a collection of variable of specific types with index) <- covered later Operations chr(x); Convert ASCII code (x) into character ord(c); Convert character (c) into ASCII code length(str);Find the length of a string (str) copy(str, x, y); Copy, starting from the x th element, y elements of string (str) pos(substr, str);Find position of substr in str val(str, x, e);Convert a string (str) into an integer (x) str(x, str);Convert an integer (x) into a string (str) concat(str1, str2, …);Combine a string (str1) with another (str2, etc.) insert(str1, str2, x);Insert a string (str1) in the x th element of another (str2) delete(str, x, y); Delete, starting from xth element, y elements of string (str) fillchar(str, x, c); Fill the string (str) with a character (c) until string is (x-1) long

Last but not least… Pascal compilers: Free Pascal (Official HKOI/CCC compiler) Dev-Pascal Quick Pascal Useful software: Notepad++ Useful website/contact: Lin Yin Long (L6D)