Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.

Slides:



Advertisements
Similar presentations
C Programming Technique – Firdaus-Harun.com
Advertisements

ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
Programming Types of Testing.
UNIT 2. Introduction to Computer Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
INTRODUCTION TO PROGRAMMING
Chapter 2- Visual Basic Schneider
Programming Fundamentals (750113) Ch1. Problem Solving
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Programming Lifecycle
Programming Concepts Chapter 3.
Software Life Cycle What Requirements Gathering, Problem definition
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.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Chapter 2: General Problem Solving Concepts
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Structured Programming (4 Credits)
The Hashemite University Computer Engineering Department
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
Pseudocode (pronounced SOO-doh-kohd)  is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled.
Program design Program Design Process has 2 phases:
GC101 Introduction to computers and programs
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
Chapter One Problem Solving
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Computer Programming.
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Programming Logic n Techniques
ALGORITHMS AND FLOWCHARTS
Problem Solving Techniques
ALGORITHMS AND FLOWCHARTS
Pseudocode & Flowcharts
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
ALGORITHMS AND FLOWCHARTS
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Problem Solving Skill Area 305.1
Programming Fundamentals (750113) Ch1. Problem Solving
Software Development Process
Introduction to Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
Presentation transcript:

Lecture 3 Computer Programming -1-

The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into three question : 1- What are the available data or data that represent the input of the program? (input) 2- What is the method or set of processes that lead to get the results from the available data? (process) 3-What are the required results or Output of the program? (output)

2-Design solution : - Dividing the problem into small steps - Then identify the solution in a sequence of steps called algorithm. 3-Write the program (source code) : compile the algorithm into a specific programming language. 4- Compilation : When testing program, the compiler may find Syntax errors in the program, in this case must be corrected and then recompile the program again

Types of Program Error There are three basic categories of program errors: 1. Syntax Errors 2. Run-time Errors 3. Logic Flaws In the first two cases when an error occurs, the computer displays an 'Error Message', which describes the error, and its cause. In the final case, the program will not show an error message but it will not do what the programmer wanted it to do.

1-Syntax Errors : These errors are the easiest to find because they are highlighted by the compiler. Error messages are given. This type of error is caused by the failure of the programmer to use the correct grammatical rules of the language. If a program has a syntax error it cannot be translated, and the program will not be executed. 2. Run-time Errors Run-time errors are detected by the computer and displayed during execution of a program. A run-time error occurs when the user directs the computer to perform an illegal operation, eg: Dividing a number by zero, Assigning a variable to the wrong type of variable

3. Logic Flaws These are the hardest errors to find as they do not halt the program. They arise from faulty thinking on behalf of the programmer. Programs with logic errors will often compile, execute, and output results. However, at least some of the time the output will be incorrect. Error messages will generally not appear if a logic error occurs, this makes logic errors very difficult to locate and correct.

Algorithm and flowchart - An Algorithm : is a finite sequence of instructions that produce the solutions to the problem and is written by any human-language. - An algorithm must ( algorithm constraint ): Be clear. Give the correct solution in all cases should not be associated a specific programming language, but can be converted to any language selected by the programmer.

Algorithm Example - write an algorithm that find the perimeter of the rectangle : 1- start 2- input : L and W 3- process : p= 2*(L+W) 4- output : print p 5- End

Flow chart Flowchart : A graphical representation of the sequence of operations in a program. Programmer prepares flowchart before coding. Note : Different symbols are used to draw each type of flowchart.

Flowchart Symbol NameSymbol بداية – نهاية Start - End مدخلات – مخرجات Input - Output معالجة Processing القرار و التفرع Decision and branching خط التدفق Flow Line

p= 2*(L+w) start End print p Flowchart Example : -Draw flowchart that find the perimeter of the rectangle. Input L,W

Example 1 : - write an algorithm and flowchart for finding the average of two numbers. Algorithm : Flowchart : average= (A+B)/2 input A and B start End print average 1-start 2-input: A and B 3-process : average = (A+B)/2 4- output : print average 5- End

Example 2 : - Write an algorithm and draw flowchart that reads two values, determines the largest value and prints the largest value. Algorithm : 1-start. 2- input : A,B 3- process : A>=B yes : A= Max No : B=Max 4- output: Max 5- End

Max =B End A >=B ? NoYes Start Input A, B Max =A Print Max Flowchart :

Example 3 : - Write an algorithm and draw flowchart to calculate the value of each of the variables C, B, A in the following equation: (1) A= X² + 2Y (2) B= 2X – 3A (3) C= A² + XB Algorithm : 1-start. 2- input : X,Y 3- process : A= X² + 2Y B= 2X – 3A C= A² + XB 4- output: A,B,C 5- end

Flowchart : Start End A=(X*X) + 2Y C= A + XB B= 2X – 3A Input X,Y print A,B,C

Homework Write an algorithm and draw a flowchart : 1) finding Area to the circle when Area = 3.14 * X. 2) finding the value to A and B( when X and y are entered by user) A=X^2+2Y, B=2X-3A.