INFS 214: Introduction to Computing

Similar documents
Copyright 2005 Department of Computer & Information Science

INFS 214: Introduction to Computing

INFS 214: Introduction to Computing

INFS 214: Introduction to Computing

INFS 214: Introduction to Computing

INFS 214: Introduction to Computing

C++ Programming Language Lecture 1 Introduction

Fundamentals of Programming Session 2

Introduction to Programming

INFS 214: Introduction to Computing

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Principles of Programming Languages. Lecture Outline

Fundamentals of Programming. Lecture 1: Introduction to C Programming

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Computer Software: Introduction

(0) introduction to the course. how to learn a programming language. (0) course structure

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1. Preliminaries

CSI32 Object-Oriented Programming

Programming Languages and Program Development

Chapter 1. Preliminaries

Lecture 01 & 02 Computer Programming

0 Introduction: Computer systems and program development

Computer Components. Software{ User Programs. Operating System. Hardware

by Pearson Education, Inc. All Rights Reserved.

Introduction to Programming

Introduction to Computers and Visual Basic.Net Pearson Education, Inc. All rights reserved.

ECS15, Lecture 10. Goals of this course 2/8/13. Mini-Review & Topic 3.2 Software. Today s agenda

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Introduction to Computing using C++ Biomedical applications WELCOME TO CIS 1.5. Introduction to the course. Course structure

Discovering Computers 2008

C H A P T E R 1. Introduction to Computers and Programming

Stating the obvious, people and computers do not speak the same language.

Compilers. Prerequisites

Outline. Program development cycle. Algorithms development and representation. Examples.

Chapter 1 Preliminaries

Low-Level Languages. Computer Programs and Programming Languages

Basic Computer Programming for ISNE. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร

Introduction to Programming: Variables and Objects. HORT Lecture 7 Instructor: Kranthi Varala

last time in cs recitations. computer commands. today s topics.

Introduction to Computers, the Internet and the Web Pearson Education, Inc. All rights reserved.

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

ENGR/CS 101 CS Session Lecture 3

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Objective: To learn meaning and concepts of programming. Outcome: By the end of this students should be able to describe the meaning of programming

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

Computer Components. Software{ User Programs. Operating System. Hardware

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

Component V Supporting Materials / Learn More Interesting Facts. Interesting Facts

Compiler Construction

PEMROGRAMAN BERORIENTASI OBJECT. Indra Gunawan, ST., M.Kom., CEH., CHFI

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

Evolution of Fortran. Presented by: Tauqeer Ahmad. Seminar on Languages for Scientific Computing

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Topic 1: Programming concepts

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Computer Fundamentals

CS101 Introduction to Programming Languages and Compilers

Lecturer: Dr. Ebenezer Ankrah, Dept. of Information Studies Contact Information:

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

Programs are: CMPSCI 105/119/120: Programming, Flowchar<ng, and Running Program Flowcharts

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Discovering Computers Chapter 13 Programming Languages and Program Development

Visual Basic Primer A. A. Cousins

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

LECTURE 1. Overview and History

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program

An Overview of the BLITZ System

IS 0020 Program Design and Software Tools

CHAPTER 1 Introduction to Computers and Java

Technology in Action. Chapter Topics. Scope creep occurs when: 3/20/2013. Information Systems include all EXCEPT the following:

Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computers and programming languages introduction

Concepts of Programming Languages

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

VB Net Debugging (Console)

1/14/2014. Introduction to CSE 1325 Object Oriented Programming (Using Java) Introduction (Cont.) Introduction

Software Development. Integrated Software Environment

Problem Solving and Program Design - Chapter 1. Cory L. Strope

INTRODUCTION TO THE COURSE

COMPUTER ORGANIZATION & ARCHITECTURE

An Introduction to Python (TEJ3M & TEJ4M)

LESSON 13: LANGUAGE TRANSLATION

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

1/31/2017. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

printf( Please enter another number: ); scanf( %d, &num2);

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

What is programming? What are computer languages and how have they evolved? What is the basic process of programming, including the tools involved?

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

PROGRAMMING Programming is a creation of a set of commands or instructions which directs a computer in carrying out a task.

Transcription:

INFS 214: Introduction to Computing Session 11 Principles of Programming Lecturer: Dr. Ebenezer Ankrah, Dept. of Information Studies Contact Information: eankrah@ug.edu.gh College of Education School of Continuing and Distance Education 2014/2015 2016/2017

Session Overview Every piece of software, from a simple word processor, such as Microsoft Notepad, to the most advanced image editing programs, such as Adobe Photoshop, is made by one or more computer programmers who use a programming language that tells a computer how to act. DR. EBENEZER ANKRAH Slide 2

Session Overview Programming is a highly complex subject that covers many different types of languages and can be used to solve a huge range of problems. This session seeks to explain the concept of programming, the types of programming languages and the types of errors that could occur in the course of programming. DR. EBENEZER ANKRAH Slide 3

Session Overview At the end of the session, the student will Understand and differentiate between the various types of programming languages Be able to give examples of programming languages Understand and identify the various types of programming errors Be able to identify the phases in the Program Development Cycle Be able to write a simple computer program for execution Understand and differentiate between the methods of testing a computer program DR. EBENEZER ANKRAH Slide 4

Session Outline The key topics to be covered in the session are as follows: Concept of Programming Types of Programming Languages Program Development Cycle Types of Errors DR. EBENEZER ANKRAH Slide 5

Reading List O Leary, T. J., & O Leary, L. I. (2014). Computer Today. Boston: McGraw Hill. (Chapter 15) DR. EBENEZER ANKRAH Slide 6

Topic One CONCEPT OF PROGRAMMING DR. EBENEZER ANKRAH Slide 7

Concept of Programming The concept of general-purpose programming in fact predates the development of computers. In the field of mathematical logic in the early 20th century, logicians created their own programming languages. Their motivation originally sprang from the concept of a proof system, a set of rules in which logical truths could be derived, mechanically. DR. EBENEZER ANKRAH Slide 8

Concept of Programming The original computer programming languages, as mentioned above, were so-called machine languages: the human and computer programmed in same language. Machine language is great for computers but not so great for humans since the instructions are each very simple and so many, many instructions are required. High-level languages were introduced for ease of programmability by humans. DR. EBENEZER ANKRAH Slide 9

Concept of Programming FORTRAN was the first high-level language, developed in 1957 by a team led by Backus at IBM. FORTRAN programs were translated (compiled) into machine language to be executed. They didn't run as fast as hand-coded machine language programs, but FORTRAN nonetheless caught on very quickly because FORTRAN programmers were much more productive. A swarm of early languages followed: ALGOL in '58, Lisp in the early 60's, PL/1 in the late 60's, and BASIC in 1966. DR. EBENEZER ANKRAH Slide 10

Concept of Programming A computer program is a set of instructions written in a computer language in order to be executed to perform a specific task. A programmer is a person who writes the required computer programs. Programmers translate the expected tasks given in human understandable form into machine understandable form by using compilers and interpreters. DR. EBENEZER ANKRAH Slide 11

Questions Individual Assignment: Differentiate between the types of programming errors Forum Question: Discuss the phases in the Program Development Cycle DR. EBENEZER ANKRAH Slide 12

Topic Two TYPES OF PROGRAMMING LANGUAGES DR. EBENEZER ANKRAH Slide 13

Types of Programming Languages A programming language is a computer language with its own syntax and grammar. Both systems and application software are written in programming languages. A programming language is a special purpose and limited language. It is a set of rules and symbols used to construct a computer program. A language used to interact with the computer. Programming languages allow programmers to code software. DR. EBENEZER ANKRAH Slide 14

Types of Programming Languages There are three major families of programming languages. These are: Machine languages Assembly languages High-Level languages DR. EBENEZER ANKRAH Slide 15

Types of Programming Languages Machine Languages The machine language comprised of 1s and 0s. It is the native language of a computer system. It is difficult to program one misplaced 1 or 0 will cause the program to fail. In early years of computer revolution, programs were written in machine language, using the binary symbols 1 and 0. All numbers, characters and special symbols were represented by eight-bit codes. DR. EBENEZER ANKRAH Slide 16

Types of Programming Languages This is also considered a low-level language because there is no programming scheme less sophisticated than the binary code. Example: 00000010 00100101 00000011 = 2 + 3 Example of codes are 1110100010101, 111010101110 10111010110100 and 10100011110111 DR. EBENEZER ANKRAH Slide 17

Types of Programming Languages Assembly Languages Assembly languages are a step towards easier programming. Assembly languages are comprised of a set of elemental commands which are tied to a specific processor. Assembly language code needs to be translated to machine language before the computer processes it. Assembly languages are English-like abbreviations representing elementary computer operations DR. EBENEZER ANKRAH Slide 18

Types of Programming Languages Assembly languages are a symbolic representation of the machine language of a specific processor. It is converted to machine code by an assembler. Usually, each line of assembly code produces one machine instruction (One-to-one correspondence). Programming in assembly language is slow and errorprone but is more efficient in terms of hardware performance. Mnemonic representation of the instructions and data. DR. EBENEZER ANKRAH Slide 19

Types of Programming Languages Assembly language replaced binary digits with symbols such as ADD, SUB for addition and subtraction, so that programming became more understandable to humans. Operating systems and utility programs were written in an assembly language. Example: ADD 1001010, 1011010, ADD OVERPAY STORE GROSSPAY LOAD BASEPAY, DR. EBENEZER ANKRAH Slide 20

Types of Programming Languages High-Level Languages High-level languages represent a giant leap towards easier programming. The syntax of HL languages is similar to English. High-level languages codes are similar to everyday English. It uses mathematical notations. A programming language which use statements consisting of English-like keywords such as "FOR", "PRINT", IF etc. Each statement corresponds to several machine language instructions (one-to-many correspondence). DR. EBENEZER ANKRAH Slide 21

Types of Programming Languages Each statement corresponds to several machine language instructions (one-to-many correspondence). It is much easier to program than in assembly language. Data are referenced using descriptive names and operations can be described using familiar symbols. Example: grosspay = basepay + overtimepay Cost = Price + Tax DR. EBENEZER ANKRAH Slide 22

Types of Programming Languages These languages were easier to use than assembly and machine language because they relied on natural language (such as English) and used fewer lines of code to execute an instruction. Some high-level languages are BASIC, COBOL, FORTRAN, and C. DR. EBENEZER ANKRAH Slide 23

Types of Programming Languages High-Level languages are divided into two groups: Procedural languages and Object-Oriented languages (OOP). DR. EBENEZER ANKRAH Slide 24

Types of Programming Languages Procedural Languages Early high-level languages are typically called procedural languages. Procedural languages are characterized by sequential sets of linear commands. The focus of such languages is on structure. Examples are C, COBOL, Fortran, LISP, Perl, HTML and VBScript. DR. EBENEZER ANKRAH Slide 25

Types of Programming Languages Object-Oriented Languages Most object-oriented languages are high-level languages. The focus of OOP languages are not on structure, but on modeling data. Programmers code using blueprints of data models called classes. Examples of OOP languages are C++, Visual Basic.NET and Java. DR. EBENEZER ANKRAH Slide 26

Types of Programming Languages What does the Computer understand? Computer only understands machine language instructions. Assembling Instructions written in assembly language must be translated to machine language instructions. An Assembler does this. One Assemble Language instruction is mapped to one Machine Language instruction. Assemble Languages are CPU specific. DR. EBENEZER ANKRAH Slide 27

Types of Programming Languages Compiling Regardless of the HL Language, all HL programs need to be translated to machine code so that a computer can process the program. Some programs are translated using a compiler. When programs are compiled, they are translated all at once. Compiled programs typically execute more quickly than interpreted programs, but have a slower translation speed. DR. EBENEZER ANKRAH Slide 28

Types of Programming Languages A compiler is a specific software that gets the whole Source Code (Computer program written in human understandable form) and translates it into Object Code (Computer Program that is in machine understandable form) all at a time. DR. EBENEZER ANKRAH Slide 29

Types of Programming Languages Interpreting Some programs are translated using an interpreter. Such programs are translated line-by-line instead of all at once (like compiled programs). Interpreted programs generally translate quicker than compiled programs, but have a slower execution speed. DR. EBENEZER ANKRAH Slide 30

Types of Programming Languages Interpreter is translating and executing one statement (command of Computer Program) of Source Code into Object Code at a time. (It means, interpreters translate and execute computer programs line by line). DR. EBENEZER ANKRAH Slide 31

Topic Three PROGRAM DEVELOPMENT CYCLE DR. EBENEZER ANKRAH Slide 32

Program Development Cycle There are four processes in the program development cycle. The following are the processes; Process 1: Analyze the Problem What must the program do? What outputs are required and in what form? What inputs are available and in what form? DR. EBENEZER ANKRAH Slide 33

Program Development Cycle Example: Find a maximum of two numbers Input two numbers, compare them and print the maximum value Inputs and outputs are decimal numbers Inputs are entered from the keyboard Result is shown on the monitor DR. EBENEZER ANKRAH Slide 34

Program Development Cycle Process 2: Design the Program Program Design involves creating an algorithm. An algorithm is a sequence of steps, by which a computer can produce the required outputs from the available inputs. An algorithm can also be considered as a step by step procedure that will provide the required results from the given inputs. Examples of algorithm: Instructions on how to develop a website, use the bank s ATM, etc. DR. EBENEZER ANKRAH Slide 35

Program Development Cycle Top-down design The main problem is split into subtasks Then each subtask is divided into simpler subtasks, etc. unless it is clear how to solve all such subtasks DR. EBENEZER ANKRAH Slide 36

Program Development Cycle Process 3: Code the Program Program Coding means expressing the algorithm developed for solving a problem, in a programming language. Once the design is completed, write the program code. Code is written in some programming language such as BASIC, Pascal, C++, Java, etc. DR. EBENEZER ANKRAH Slide 37

Program Development Cycle Process 4: Testing the program Initially, almost all programs may contain few errors, or bugs. Testing is necessary to find out if the program produces a correct result. Usually it is performed with sample data. Ultimate test is to run the program to see if the outputs are correct for the given inputs Debugging is the process of locating and removing errors. DR. EBENEZER ANKRAH Slide 38

Topic Four TYPES OF ERRORS DR. EBENEZER ANKRAH Slide 39

Types of Errors Types of Program Errors There are three major types of program errors. These are as follows: Syntax Errors: Violation of syntactic rules in a Programming Language generates syntax errors. It is also caused by wrong grammar, i.e., breaking the rules of how to write the language. Forgetting punctuation, misspelling keyword etc. Interpreter or Compiler finds it in Syntax Check Phase. DR. EBENEZER ANKRAH Slide 40

Semantic Errors: Doing logical mistakes causes semantic errors in source code. The program completes execution, but delivers incorrect results. Interpreters and Compilers cannot notice them, but on execution, they cause unexpected results. DR. EBENEZER ANKRAH Slide 41

Types of Errors Run-time Errors: Occur on program execution. Mostly caused by invalid data entry or tries to use not existing resources. It occurs on run time and may crash the program execution DR. EBENEZER ANKRAH Slide 42

Types of Errors Types of Data The types of date are: Numeric Data Integer data, i.e., whole numbers 10, 25, -45, etc Floating point data have a decimal point 23.0, -5.0 Character data (alphanumeric) All the characters you can type at the keyboard Letters and numbers not used in calculations Boolean data TRUE/FALSE DR. EBENEZER ANKRAH Slide 43

References Hutchinson, S. E., & Sawyer, S. C. (2013). Computers: The user perspective. Boston: Irwin McGraw-Hill. O Leary, T. J., & O Leary, L. I. (2014). Computer Today. Boston: McGraw Hill. Williams, B. K., & Sawyer, S. C. (2014). Using Information Technology: A practical introduction to computers and communications (11 th ed.). McGraw-Hill Education. DR. EBENEZER ANKRAH Slide 44