PROGRAMMING: What’s It All About?

Slides:



Advertisements
Similar presentations
Algorithms 10 IST – Topic 6.
Advertisements

CS101: Introduction to Computer programming
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Basics of Computer Programming Web Design Section 8-1.
Computer Science 101 Overview of Algorithms. Example: Make Pancakes Prepare batter Beat 2 eggs Add 1 tablespoon of brown sugar Add 1 cup of milk Add 2.
Designing Algorithms Csci 107 Lecture 4. Outline Last time Computing 1+2+…+n Adding 2 n-digit numbers Today: More algorithms Sequential search Variations.
ITEC113 Algorithms and Programming Techniques
Chapter 2: Algorithm Discovery and Design
Program Design and Development
Chapter 2: Design of Algorithms
Computer Science 1620 Programming & Problem Solving.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Adapted from slides by Marie desJardins
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
 Problem Analysis  Coding  Debugging  Testing.
LET’S FINISH - TODAY’S OBJECTIVE: Create an algorithm to direct a human “robot” from one part of the room to another. Create an algorithm to direct a human.
Program design Program Design Process has 2 phases:
Understand Problem Solving Tools to Design Programming Solutions
REPETITION CONTROL STRUCTURE
Basics of Computer Programming
ALGORITHMS AND FLOWCHARTS
Programming Mehdi Bukhari.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Understand Problem Solving Tools to Design Programming Solutions
Introduction To Flowcharting
Basics of Computer Programming
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Basics of Computer Programming
Basics of Computer Programming
Programming Fundamentals
Algorithm and Ambiguity
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Computer Programming.
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Problem Solving Techniques
Programming & languages
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
T. Jumana Abu Shmais – AOU - Riyadh
ALGORITHMS AND FLOWCHARTS
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm Discovery and Design
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Algorithm and Ambiguity
Fundamentals of visual basic
ICT Programming Lesson 3:
Flowcharts and Pseudo Code
Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
Software Development Techniques
Presentation transcript:

PROGRAMMING: What’s It All About? Hele-Mai Haav: February 2002 PROGRAMMING: What’s It All About? Though, thy beginning was small, yet thy end will be very great. JOB 8:7

INPUT Ingredients: sugar, flour recipe OUTPUT Software Hardware Oven/baker (mixing, pouring, heating etc.) ALGORITHM is the formal written version of recipe Program is precise representations of algorithms written in special computer-readable language like Basic, C, C++, Pascal, Cobol… OUTPUT

Algorithm A formula or set of steps for solving a particular problem. To be an algorithm, a set of rules must be unambiguous and have a clear stopping point. Algorithms can be expressed in any language, from natural languages like English or French to programming language like FORTRAN. We use algorithms every day. For example, a recipe for baking a cake is an algorithm. Most programs, with the exception of some artificial intelligence applications, consist of algorithms. Inventing elegant algorithms -- algorithms that are simple and require the fewest steps possible -- is one of the principal challenges in programming.

Summing problem Step 1. make a note of the number 0 Step 2. proceed through the list, adding each employee's salary to the noted number Step 3. having reached the end of the list, produce the noted number as output

Does this algorithm do the job? Text of the algorithm is short and fixed in length. The process it describes and controls depends on the length of the employee list and can be very long.

Does this algorithm do the job? Let us have two companies: with 1 empl. with 1 million empl. They both can use the same algorithm for solving salary summation problem. Only a single noted number is required for both.

What we have? 1. fixed algorithm 2. a variety of possible inputs the precise duration and nature of the process depends on inputs .

Algorithm- precise order of the actions to be performed. The order in which the basic actions are carried out is crucial. The algorithm must contain control instructions to "push" the processor in this or that direction, telling it what to do at each step and when to stop and say "I'm done".

CONTROL STRUCTURES Sequence control - one process occurs immediately after another "do A followed by B" "do A and then B" A B

CONTROL STRUCTURES Selection structure, or if-then-else structure represents conditional program logic "if Q then do A" "if Q then do A otherwise do B" Q is some condition Can be true or false False True Q? A B C

CONTROL STRUCTURES A A A Iteration structure or looping structure describes occurrence of one or more processes one or more times. - Bounded iteration "do A exactly N times" N is a number - Conditional iteration do-while "while Q do A" do-until "repeat A until Q" No >N A Yes True Q? A False True A Q? False

Summing problem Let us assume the following input: 1. list of employees and their salaries 2. total number of the employees in the list, designated by letter N

Summing problem algorithm 1.Make a note of 0 Point to the first salary on the list 2. Do N-1 times the following 2.1. add the salary pointed at to the noted number 2.2. point to the next salary 3.Add the salary pointed at to the noted number 4.Produce the noted number as output

Diagrams for algorithms Flowcharts

Programs are written in some programming languages which allow the use of only special combinations of selected symbols and keywords. "please read the value X from the input" "how about getting me a value of X" INPUT X READ X

A typical programming language includes : rules for writing control structures ways of defining various types of data (numeric, textual, etc) formats for the basic instructions

Summing algorithm for summing the numbers from 1 to N might be written in Basic as follows: REM Summing INPUT N SUM = 0 FOR INDEX = 1 TO N SUM = SUM + INDEX NEXT INDEX PRINT "Sum of the first N digits is"; SUM END RUN

SUM = 0 sets variable SUM to value 0 FOR INDEX = 1 TO N FOR-NEXT loop repeats the loop fixed number of times At the top of the loop index variable INDEX is given the value 1 NEXT INDEX returns control to the top of the loop and variable INDEX is automatically incremented by 1, and looping continues until INDEX value exceeds the final limit N. Then the control goes to the statement following the NEXT statement PRINT "Sum of the first N digits is"; SUM prints the value of the variable SUM