Introduction to a Programming Environment

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

Introduction to Programming in C++ John Galletly.
Introduction to C Programming
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
COMP 4—Power Tools for the Mind1 PowerTools What’s in the Box? Turing 1: An Introduction to Programming You will learn elementary computer programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Chapter 2: Input, Processing, and Output
Chapter 16 Programming and Languages: Telling the Computer What to Do.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Chapter 1 Program Design
Introduction to C Programming
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Computer Science 101 Introduction to Programming.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 9 Interactive Multimedia Authoring with Flash - Introduction to Programming “Computers and Creativity” Richard D. Webster, COSC 109 Instructor.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter Introduction to Computers and Programming 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CPS120: Introduction to Computer Science
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Evolution of Programming Languages Generations of PLs.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
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.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Programming With C.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
CPS120: Introduction to Computer Science
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Programming, an introduction to Pascal
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
CPS120: Introduction to Computer Science Variables and Constants.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Software Development Languages and Environments. Computer Languages Just as there are many human languages, there are many computer programming languages.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Component 1.6.
A variable is a name for a value stored in memory.
Chapter 10 Programming Fundamentals with JavaScript
CSCI-235 Micro-Computer Applications
Unit# 8: Introduction to Computer Programming
TRANSLATORS AND IDEs Key Revision Points.
Translators & Facilities of Languages
Chapter 10 Programming Fundamentals with JavaScript
1.3.7 High- and low-level languages and their translators
Presentation transcript:

Introduction to a Programming Environment

What is a Computer Program? A program is a set of step-by-step instructions to the computer telling it to carry out the tasks that you want it to do to produce the results you want.

coding (the construction phase) What is Programming? Programming consists of two distinct steps: algorithmic design (the problem solving stage, analogous to the work of an architect designing a building) coding (the construction phase)

What do I need to support algorithm design? Some time A pen Some paper We will have a great deal to say about algorithm design in the remainder of this module. But for now we will focus on coding issues

What do I need to Support Coding? A programming language to express your ideas a set of tools to design, edit, and debug your code either a compiler to translate your programs to machine code a machine to run the executable code or an interpreter to translate and execute your program

Levels of Programming Languages Machine language Assembly Language High Level Languages

Machine Language Actual binary code that gives basic instructions to the computer. These are usually simple commands like adding two numbers or moving data from one memory location to another. Different for each computer processor

Assembly Language A way for humans to program computers directly without memorizing strings of binary numbers. There is a one-to-one correspondence with machine code. For example ADD and MOV are mnemonics for addition and move operations that can be specified in single machine language instructions. Different for each computer processor

High-level language Permits humans to write complex programs without going step-by step. High-level languages include Pascal, C, C++, FORTRAN, Java, Visual Basic, and many more. One command in a high-level language may translate to tens of machine language instructions.

Computers can only run machine language programs directly. Assembly language programs are assembled, or translated into machine language. Likewise, programs written in high-level languages, like Pascal, must also be translated into machine language before they can be run. To do this translation is to compile a program. Let’s take a look at a development environment based on a Pascal Compiler

Introduction to a High-Level Development Environment Free Pascal The compiler and development environment referred to here can be downloaded from http://www.freepascal.org/

The Integrated Development Environment (IDE) screen immediately after startup

Creating a New Program Press ALT then select “File” then “New” You should get the screen below

Entering Code Type in the code below – save it by selecting File>Save or by pressing F2

Points to Note Program ends with a Full Stop This line indented using TAB key Lines end with a semicolon

Compile and Run Having created the program we now need to compile it to create an executable (machine code) file Do this by pressing ALT then selecting Compile – or press ALT F9 If there are no errors you will now have an executable program to run it press ALT then select Run

Compile and Run When the program runs you will get a brief glimpse of the output then you are returned to the IDE To see more of the output press ALT F5 or select Debug>User Screen. When you have inspected the output press ALT F5 again to get back to the IDE

Points to Note The Free Pascal website http://www.freepascal.org/ contains lots of documentation to help you learn to work in the environment The compiler will help you identify any mistakes in your programs Work through the tutorial and practical exercises associated with these lecture slides to gain some familiarity with the environment

Another Useful Website To supplement the practical exercises work through the first few exercises in the online tutorial at: http://www.taoyue.com/tutorials/pascal/contents.html

Programming Experience If you have a little programming experience you should have no difficulty picking up the basics of Pascal from the online tutorial If you have no programming experience you will need to work through them more thoroughly You do not need to become an expert Pascal programmer for this module but you need to be comfortable with the basics Including how to work with data

A Few Words about Variables and Data types This topic is covered in the online tutorials – if you find the ideas difficult be sure to spend some time working through them.

Use of variables In order to solve problems programs may need to hold information for a short while or for their entire duration. This may be necessary when making comparisons or processing data into another form. This information is held in VARIABLES

What are variables? A memory location used to store data Where the values can change Where the variables are given a type which determines: The kind of data to store The size of the data storage facility The location of the store

Variables Variables are memory storage areas which as the name suggests are capable of changing their contents. For example a variable called number may hold a number 10, this may then be changed to 8 and then to –6. Changing the value of a variable involves destroying the record in memory and replacing it with a new value. To identify a variable you must supply it with a name so that the computer knows where to store new values and retrieve existing ones from. Variable names must always begin with a letter, e.g. Name, City, TR500 etc. but not 51Avenue.

Data Types Different types of data can be stored in the computer’s memory and it is important the you understand and are comfortable dealing with the different types. The types you are most likely to use are: String, Integer, Real, Currency, Date and Boolean.

Variable Types Real - A number with something after the decimal point (e.g. 3.5) Integer - A whole number with nothing after the decimal point. (e.g. 3) String – any ASCII symbols or characters - (e.g. “Name”) Boolean - True or False Date – from Jan1 001 to Dec 31st 9999

Declaring Variables Give every variable a name You can include numbers, letters and underscore characters but no spaces or keywords. Don’t begin with a number though! Use meaningful words Don’t make the words too long – you may have to type them in a few times!

Declaring Variables It is good programming practice to declare variables that are to be used with the variable names. This can be done at the beginning of an event procedure. Examples Var Temp : String Var Count : Integer

Assigning values Assign values using the := symbol As a declaration, X:=1 does not mean that the value of X is the same as 1, it means assign X the value of 1. This value will be stored until a new value is stored in it. Example X := 3 Y := 6 X := 4 Z := 1 What is X now? X = 4

Using Constants Constants hold values similar to variables, but as the name suggests the value cannot change. Use it for values such as Pi, g, conversion factors etc. The values are set at compile time rather than runtime which speeds things up. Constant names should always be in upper case and are set using the Const keyword. They are declared like this: Const CL_Per_BOTTLE : integer; Const PI : real;

This is not a course in Pascal programming But Pascal is a very useful environment for testing out our algorithms Be prepared to spend some time at this stage becoming familiar with the development environment This will pay off later when we consider the design of more complex programs

Review Questions What is machine code how does it differ from high-level program code? Name some commonly used high-level languages. What are the advantages of using high-level languages? What is the overall structure of a Pascal program? How is the semicolon used in Pascal? When must it be used?

Review Questions What punctuation mark comes at the end of every Pascal program? What is the difference between compilation and execution of a program? What syntax errors are novice Pascal programmers most likely to make?

Research Questions Who was Blaise Pascal? Who developed the Pascal language? What was its original purpose?