Programming Fundamentals 1 st lecture. ELTE 2/42 2014. 12. 11.2014. 12. 11.2014. 12. 11. Content  Steps of solving problems – steps of writing a computer.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Requirements Engineering Processes – 2
Simplifications of Context-Free Grammars
Mathematical Preliminaries
Variations of the Turing Machine
2. Getting Started Heejin Park College of Information and Communications Hanyang University.
Angstrom Care 培苗社 Quadratic Equation II
1
1 Vorlesung Informatik 2 Algorithmen und Datenstrukturen (Parallel Algorithms) Robin Pomplun.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman
Introduction to Algorithms 6.046J/18.401J
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 5: Repetition and Loop Statements Problem Solving & Program.
Chapter 3: Top-Down Design with Functions Problem Solving & Program Design in C Sixth Edition By Jeri R. Hanly & Elliot B. Koffman.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
Solve Multi-step Equations
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Intel VTune Yukai Hong Department of Mathematics National Taiwan University July 24, 2008.
Turing Machines.
Lilian Blot TO PROGRAMMING & PYTHON Introduction Autumn 2012 TPOP 1.
PP Test Review Sections 6-1 to 6-6
Modern Programming Languages, 2nd ed.
LIAL HORNSBY SCHNEIDER
Bellwork Do the following problem on a ½ sheet of paper and turn in.
1 University of Utah – School of Computing Computer Science 1021 "Thinking Like a Computer"
Exercise 1: Install PC Software & NXT Firmware
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
1 Chapter 4 The while loop and boolean operators Samuel Marateck ©2010.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
While Loop Lesson CS1313 Spring while Loop Outline 1.while Loop Outline 2.while Loop Example #1 3.while Loop Example #2 4.while Loop Example #3.
CS101: Introduction to Computer programming
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
CS 240 Computer Programming 1
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 15 Programming and Languages: Telling the Computer What to Do.
Analyzing Genes and Genomes
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
Lilian Blot CORE ELEMENTS SELECTION & FUNCTIONS Lecture 3 Autumn 2014 TPOP 1.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
Topic 16 Sorting Using ADTs to Implement Sorting Algorithms.
Energy Generation in Mitochondria and Chlorplasts
Instructor: Shengyu Zhang 1. Content Two problems  Minimum Spanning Tree  Huffman encoding One approach: greedy algorithms 2.
Languages for IT & CS Pseudo-code What HTML isn’t Early history Compiling & interpreting Classifying languages The process of programming.
User Defined Functions Lesson 1 CS1313 Fall User Defined Functions 1 Outline 1.User Defined Functions 1 Outline 2.Standard Library Not Enough #1.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
L6:CSC © Dr. Basheer M. Nasef Lecture #6 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
Presentation transcript:

Programming Fundamentals 1 st lecture

ELTE 2/ Content  Steps of solving problems – steps of writing a computer program Steps of solving problems  Languages used when programming Languages used when programming  The alogirithm The alogirithm  The specificaion The specificaion  Languages describing and algorithm – structogram Languages describing and algorithm  Coding a program – programming tool Coding a program

ELTE 3/ Steps of solving problems Example: build a house  What can you see from the process?  What is behind? 1. Assess the needs (aspects: size of family, their idea, money) 2. Design (plan, building material needs, engineer) 3. Organize (schedule, contractor…) 4. Building operations (supply material, building / contractor…) 5. Put in practice (have a look – how fancy, try out – how good) 6. Move in, live in (make corrections, detect problems)

ELTE 4/ Steps of creating a computer program 1. Specify (from what?, what?)  specification 2. Design (with what?, how?)  data and algorithm desc. 3. Coding (how (computer)?)  program source code representation + implementation 4. Testing (any bugs?)  error list (diagnosis) 5. Search for bugs (where is the bug?)  bug location 6. Correction (how is it correct?)  correct program 7. Quality assurance (Q&A), efficiency (can we make better?, how?)  good program 8. Documenting (how does it work? etc…)  usable program 9. Usage, maintenance (still works?)  durable program

ELTE 5/ Language tiers Living language = English  Specification  Algorithm description  Programming language  Computer language (machine code) Converge the languages (English  Computer)

ELTE 6/ The Algorithm Usage of drink dispensing machine: 1. Choose the drink! 2. Insert 1€! 3. Press the proper button! 4. Wait until the drink runs out! 5. Get the dring! 6. Drink it!

ELTE 7/ The Algorithm  Executable (interpreter exists)  Can be executed step by step  The steps themselves are also algorithms  Exactly defined, with given order of steps  The description is finite, however the execution time can be infinite

ELTE 8/ The Algorithm Usage of drink dispensing machine: 1. Choose the drink! 2. Insert 1€! 3. Press the proper button! 4. Repeat look at the glass! Until the drink runs out! 5. Get the dring! 6. Drink it! New element: Repetition based on a condition

ELTE 9/ The Algorithm Usage of drink dispensing machine: 1. Choose the drink! 2. If you have 1€ then Insert 1€! otherwise Insert 5 x 20 cents! 3. … New element: choice from two options, (can also be non-deterministic)

ELTE 10/ The Algorithm Insert 5 x 20 cents: 1. Repeat 5 times: Insert one 20 cents! New element: repeat given times

ELTE 11/ The Algorithm Structural elements of an algorithm:  Sequence (execute step by step)  Fork (choice from 2 or more activities based on condition)  Cycle (repeat given times, or until a condition turns true)

ELTE 12/ Specification 1. Input data (identifier, domain set, unit) 2. What we know about the input (precondition) 3. Results (identifier, domain, …) 4. The rule how to calculate the result (post condition) 5. Requirements against the solution 6. Restrictions 7. Definitions of the applied notions

ELTE 13/ Specification Specification has to be 1. Exact, full 2. Short, compact, formalized 3. Expressive, understandable Specification tools 1. Text description 2. Mathematical formulas

ELTE 14/ Example: triangle (specification) Problem: Is it true that given 3 numbers represent the side lengths of a right angle triangle? Specification: Real  Input: x,y,z:Real Logical  Output: possible:Logical  Precondition: x>0 and y>0 and z>0  Post condition: possible=(x 2 +y 2 =z 2 ) Comment: we suppose z is the length of hypotenuse

ELTE 15/ Example: triangle (algorithm) Algorithm : Comment: Later we will not include In and Out in our algorithms In: x,y,z [x>0 and y>0 and z>0] possible:=(x 2 +y 2 =z 2 ) Out: possible

ELTE 16/ Example: triangle (algorithm) Another algorithm (without In and Out): We can introduce helper (internal, own) variables. xx:=x 2 yy:=y 2 zz:=z 2 possible:=(xx+yy=zz)

ELTE 17/ Example : quadratic equation (specification) Problem: Let’s specify one root of a quadratic equation! The equation is: ax 2 +bx+c=0 Questions:  What is the solution? – output  What does it mean: „being a solution”? – post condition  Does there a solution exist? – precondition  Are we sure there is only one solution? – output/post condition

ELTE 18/ Example: quadratic equation (specification) Specification 1 : Real  Input: a,b,c:Real Real  Output: x:Real  Precondition: –  Post condition 1 : ax 2 +bx+c=0 Remark: this post condition does not provide us with information how to create the algorithm. No worries, let’s try again!

ELTE 19/ Example: quadratic equation (specification) Specification 2 : Real  Input: a,b,c:Real Real  Output: x:Real  Precondition: a  0 What if we allowed?  Post condition 2 : Open questions:  Is there always a solution?  Is there only one solution?

ELTE 20/ Example: quadratic equation (specification) Extend the output: Real, Boolean  Output: x:Real, exists:Boolean  Post condition: exists=(b 2  4*a*c) and exists  Open question:  Is there only one solution? – homework

ELTE 21/ Example: quadratic equation (specification) d:=b 2 -4*a*c exists:=d  0 exists? True way False way IN Algorithm :

ELTE 22/ Example: quadratic equation (specification) Algorithm in another representation: Program QuadraticEquation: d:=b 2 -4*a*c exists:=d≥0 If exists then Program end.

ELTE 23/ Languages for algorithms  Text description  Describe by sentences  Pseudo code  Describe with drawing  Flow chart  Structogram

ELTE 24/ Example flow chart

ELTE 25/ Structogram (and pseudo code)  Sequence:  Fork (2way):  Fork (more): Statement1Statement2 If Condition then Statements1 else Statements2 End if Statements2 End if Fork In case Conition1:Statements1 In case Conition2:Statements2 … … Otherwise Statements otherwise End fork Statement1 Statement2 Condition Statements1Statements2 Condition1Condition2…Otherwise Statements1Statements2…Statements

ELTE 26/ Structogram (and pseudo code)  Loops:  How to draw structogram:  Text editor / spreadsheet  Specific tools (e.g. NSD)NSD Loop while Condition Statements End loop Loop Statements Until Condition End loop Loop i=from 1 to n Statements End loop Condition Statements Condition Statements i=1..n Statements

ELTE 27/ Coding (programming tool)  Framework (tool): Code::Blocks  Download:  Installation: easy

ELTE 28/  At first startup: Choose compiler Coding (programming tool)

ELTE 29/  Steps of usage: 1. Create a project, the type determines the platform of you want to deploy to. Create a new project 2. sablon (template) választása: Console application Coding (programming tool)

ELTE 30/  Steps of usage:  workspace of project on the disk project name project root folder Coding (programming tool)

ELTE 31/  Further steps of usage:  workspace of project on the disk Project name Project root folder projektfájl- név Project file name with full path Coding (programming tool)

ELTE 32/  Further steps of usage:  Choose compiler  Finalize compiler development version? debug dirs final version? final version dirs Coding (programming tool)

ELTE 33/  Our environment:  on the disk:  in framework: browse program Coding (programming tool)

ELTE 34/  Our environment:  on disk:  in framework: Coding (programming tool)

ELTE Szlávi-Zsakó: Programozási alapismeretek 1.35/  Compiling our first program Coding (programming tool)

ELTE Szlávi-Zsakó: Programozási alapismeretek 1.36/  The output of compilation:  on the disk: Codeing (programming tool)

ELTE 37/  The output of compilation:  on the disk: Coding (programming tool)

ELTE 38/  Our first program:  the content of main.cpp : #include #include using namespace std; int main() { cout << "Hello world!" << endl; cout << "Hello world!" << endl; return 0; return 0;} Coding (programming tool)

ELTE 39/  The project source file:  The content of firstProg.cbp : (mily meglepő!) Coding (programming tool)

ELTE 40/  Run the exe in console:  „compilation” –  run (the last compiled) –  compile & run –  the console looks like this: Start the exe directly from file system! What do you experience? Why? returned value execution time The output of the program Coding (programming tool)

Programming Fundamentals End of 1 st lecture