Chapter 2 – part a Brent M. Dingle Texas A&M University

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Advertisements

Chapter 1 - An Introduction to Computers and Problem Solving
 Introduction to Programming History of programming.
Chapter 1 Program Design
The Art of Programming Top-Down Design. The Art of Problem Solving The art of problem solving is the transformation of an English description of a problem.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
© Prentice-Hall, Inc Definition  Computer - An electronic device that has the ability to store, retrieve, and process data and can be programmed with.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
© Prentice-Hall, Inc Definition  Computer - An electronic device that has the ability to store, retrieve, and process data and can be programmed with.
Chapter 1 Program Development Asserting Java © Rick Mercer.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Software Basics. Some Pioneers Charles Babbage Analytical Engine Countess Ada Lovelace First Programmer ? John Von Neumann storing instructions in memory.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
The Hashemite University Computer Engineering Department
Fall 2001(c)opyright Brent M. Dingle 2001 Simple Sorting Brent M. Dingle Texas A&M University Chapter 10 – Section 1 (and some from Mastering Turbo Pascal.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Software Engineering Algorithms, Compilers, & Lifecycle.
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Buffer Whenever a read or readln is executed and you type a line of data terminated by hitting ENTER, that line, along with the CR/LF end of line marker.
1 Chapter 4 - Control Statements: Part 1 Outline 4.1 Introduction 4.4 Control Structures 4.5 if Selection Structure 4.6 if/else Selection Structure 4.7.
Problem Solving & Computer Programming
ALGORITHMS AND FLOWCHARTS
Algorithms and Problem Solving
Chapter 3 Program Design
INTRODUCTION TO PROBLEM SOLVING
Unit 3: ALGORITHMS AND FLOWCHARTS
CSCI-235 Micro-Computer Applications
ALGORITHMS AND FLOWCHARTS
Introduction to Computers and Java
CS1371 Introduction to Computing for Engineers
Introduction to Programmng in Python
Introduction to Computer Programming
Understand the Programming Process
Chapter 1 Program Development
Computer Programming.
ALGORITHMS AND FLOWCHARTS
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
Solving Radical Equations
Unit# 9: Computer Program Development
Problem Solving Techniques
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Introduction to pseudocode
Chapter 4 Functions Objectives
(Course Introduction)
Objective of This Course
An Introduction to VEX IQ Programming with Modkit
ALGORITHMS AND FLOWCHARTS
Computational Thinking for KS3
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Understand the Programming Process
Programming We have seen various examples of programming languages
Solving Radical Equations
Algorithm and Ambiguity
Algorithms and Problem Solving
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
Chapter 13 Conditional Repetition
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
Presentation transcript:

Chapter 2 – part a Brent M. Dingle Texas A&M University CPSC 110 - Pascal Chapter 2 – part a Brent M. Dingle Texas A&M University

Chapter 2 Some history of Computer Science Some basic concepts of programming A short introduction to Pascal Some style conventions for programming.

Back in the day You ever wonder why there are some computer stores named Babbages ? Around 1822 Charles Babbage developed an analytical engine. Which was very similar in design to today’s computers. This would be a good topic to investigate on your own.

Ada Augusta Ada Augusta was friend and colleague to Charles Babbage. She was the daughter of the poet Byron and eventually the countess of Lovelace. She is often referred to as the first computer programmer.

Algorithms An algorithm is a set of instructions that leads to the solution of a problem. Synonyms for algorithm are: Recipe Method Directions Routine

Program A program is an algorithm expressed in a language that a computer can understand. Languages which a computer can understand are thus called programming languages.

Word History – algorithm As a side note, the word algorithm was once closely related to the word algebra. This is interesting only to the extent that programming languages can be related to algebraic spaces (in simplistic terms).

Expressing Algorithms There are a number of ways to express an algorithm. Sometimes algorithms are expressed in mathematical terms, sometimes in plain English, sometimes in pseudocode, and there are other ways. If an algorithm is ‘good’ then no matter how it is expressed it should be possible to show that it is equivalent (i.e. the same) and successfully solves the proposed problem regardless of how it is expressed.

Sample algorithm to count red cars in a list. Get the list of cars. Set a counter to zero. For each car in the list do the following: Get the color of the ‘current’ car. If the color is red then add 1 to the counter. Declare the number of red cars to be the value of the counter.

Discussion of algorithm - input Notice the algorithm requires input or data – specifically it requires that a list of cars be given along with their color. Most algorithms will require some form of input or data on which to perform some type of operation.

Discussion of algorithm – output The algorithm also provides feedback to the user – specifically it states the number of red cars found in the list. This feedback is referred to as output. Most algorithms will provide some form of feedback, or output. Usually this feedback is an answer to a problem or question.

Discussion of algorithm – termination Notice that the above algorithm eventually ends – when it gets to the end of the list of cars. Not all algorithms end. Algorithms that do NOT end are sometimes referred to as partial algorithms. Algorithms that end are referred to as total algorithms.

Program Design – 2 Phases Problem solving phase Implementation phase

Problem solving phase This is where the algorithm to solve the problem is developed. This may be done in a variety of ways, but the general rules for doing so stay the same.

Problem solving phase Number One Rule Be certain the task is completely and precisely specified (i.e. the problem is well defined). Identify the expected input (where it comes from, in what form is it, etc) to the program. Identify the desired output (form, content, restrictions, etc) of the program. Understand exactly what must be done with/to the input to produce the output.

Problem solving phase 3 Steps If you follow the Number One Rule you will find the below 3 steps of the problem solving phase easier to perform. Problem Definition Algorithm Design Desktop Testing

Problem solving phase Step 1 – Problem Definition Determine if the problem is well defined (and if a solution exists). If it is not gather the necessary information to make it well defined: Ask questions Collect data Restate the problem etc. Write down the problem as it is understood !

Problem solving phase Step 2 – Algorithm Design State what processing needs to be done. Identify variables needed, substeps necessary, etc. Write it down in a step-by-step form: Flow chart English Pseudocode Whatever works for you. DOCUMENT THIS PROCESS !!!

Problem solving phase Step 3 – Desktop Testing Test your algorithm. Do this In your head On a piece of paper Using someone else, etc. Conduct multiple tests ! Try to find cases where the algorithm will NOT work. Repeat steps 2 and 3 (and 1) as often as needed until a ‘good’ algorithm is created.

Implementation phase 2 Steps Coding the algorithm as a program. Testing the program.

Implementation phase Step 1 – Coding At this point, if you did the problem solving phase correctly, you have a ‘good’ algorithm. All you need to do is write the algorithm in a language that the computer can understand, in our case the language will be Pascal. This step takes practice, practice, practice. =)

Implementation phase Step 2 - Testing Test your program ! Test it thoroughly ! Run it using various data/input. Try to get it to break. Ask someone else to test it. Document all cases that are known to cause it to fail – fix them (if possible).

Sample Problem Pretend someone tells you: “I want a program that will take the first derivative of my math equations.” What questions would you ask to aid in achieving the Number One Rule? (think about this before going to the next slide)

Sample problem - some questions What type of equations? Polynomial? Trigonometric? How many variables? Derivative with respect to which variable? Will fractions be allowed as coefficients? Are any variables raised to fractional powers? Or to roots (e.g. square root of x)? Can you think of any more… ?

Moving on… Now we will begin a brief discussion on the Pascal language. We will look at its history and some of the commands it uses.

Pascal – the language Pascal is a high level, general purpose language. It was developed by Niklaus Wirth (and colleagues) in the late 1960s and early 1970s. Notice the dialect of Pascal we will be using is Turbo Pascal, which is slightly different than standard Pascal.

Pascal – the name Pascal the language was named after the mathematician Blaise Pascal. While Blaise Pascal did not create a computer, he did create a rather sophisticated adding machine. He also contributed a bit to the development of Math – ever heard of Pascal’s triangle?