Basic problem solving CSC 111.

Slides:



Advertisements
Similar presentations
CS 240 Computer Programming 1
Advertisements

Solving Problems with Computers
Exercise (1).
ME 142 Engineering Computation I Fundamentals of Procedural Computer Programming.
Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK
CS 240 Computer Programming 1
Chapter 1 Pseudocode & Flowcharts
Fundamentals of Algorithms MCS - 2 Lecture # 4
II N T R O D U C T I O N PP R E T E S T DD E S I G N I N G A L G O R I T H M DD E S I G N I N G F L O W C H A R T GG E N E R A L R U L E S F.
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Developing logic (Examples on algorithm and flowchart)
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
CHAPTER 4: ALGORITHM 4.1 Introduction stages identified in the program development process: 1. Problem analysis and specification 2. Data organization.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing.
CSC141 Introduction to Computer Programming
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Flowcharts.
ITEC113 Algorithms and Programming Techniques
Chapter 2: General Problem Solving Concepts
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter 1 Pseudocode & Flowcharts
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
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.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering Problem Solving and Logic.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
CSC 111. Solving Problems with Computers Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem.
The Hashemite University Computer Engineering Department
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
FLOWCHARTING AND ALGORITHMS
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Program Design & Development EE 201 C7-1 Spring
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Management Information System Section (211 NMA course) Introduction to Programming.
Chapter One Problem Solving
Program design Program Design Process has 2 phases:
GC101 Introduction to computers and programs
INTRODUCTION TO PROBLEM SOLVING
Chapter One Problem Solving
Chapter 2- Visual Basic Schneider
Algorithms An algorithm is a sequence of steps written in the form of English phrases that specific the tasks that are performed while solving the problem.It.
Lecture 2 Introduction to 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.
Programming Logic n Techniques
Computational Thinking
Computational Thinking
Chapter 1 Pseudocode & Flowcharts
Unit# 9: Computer Program Development
PROBLEM SOLVING CSC 111.
Pseudocode & Flowcharts
Programming Funamental slides
الفصل الثاني الخوارزمية
Chapter 2- Visual Basic Schneider
Chapter 1 Pseudocode & Flowcharts
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
ME 142 Engineering Computation I
Basic Concepts of Algorithm
Chapter 1 Pseudocode & Flowcharts
Presentation transcript:

Basic problem solving CSC 111

Learning Objectives In this lecture we will learn Basic steps for designing computer program Algorithm Flow Chart Computer Programming -1

Solving Problems Stages Problem Definition Define the main Problem Problem Analysis Determine the inputs, outputs, Arithmetic & logic operations Design Solution Identify the required step for computer to do Computer Programming -1

Problem Definition Write a Program to Print the Sum of two integer Numbers Write a program to Print the Average of three integer numbers Write a program to print the volume of a cube and the sum of it’s surfaces’ areas Computer Programming -1

Problem Analysis Write a Program to Print the Sum of two integer Numbers Inputs : First Number Second Number Operations : Summation = first + second Output : The summation Computer Programming -1

Problem Analysis Write a program to Print the Average of three integer numbers Inputs : First Number Second Number Third Number Operations : Average = (first + second + third ) / 3 Output : The Average Computer Programming -1

Problem Analysis Write a program to print the volume of a cube and the sum of it’s surfaces’ areas Inputs : Side Length Operations : Volume = side * side * side Surface area = ( side * side ) * 6 Output : The Volume The surface area Computer Programming -1

Solving Problems Stages Problem Definition Algorithm Problem Analysis Solution Design Design a solution for the problem by writing an algorithm or drawing a flow chart Flow Chart Computer Programming -1

Basic steps for designing a solution Read all the inputs Calculate operations Print the output Computer Programming -1

Algorithms Write a Program to Print the Sum of two integer Numbers Start the program Read the first number and save in the variable ( N1 ) Read the second number and save in the variable ( N2 ) Sum the both numbers and save the result in the variable ( Sum )  Sum = N1 + N2 Print the variable ( Sum ) End the program Computer Programming -1

Algorithms Write a program to Print the Average of three integer numbers Start the program Read the first number and save in the variable ( num1 ) Read the second number and save in the variable ( num2 ) Read the third number and save in the variable ( num3 ) Sum the three numbers and save the result in the variable ( result )  result = num1 + num2 + num3 Divide the variable ( result ) by 3 and save the result in variable ( Average )  Average = result / 3 Print the variable ( Average ) End the program Computer Programming -1

Algorithms Write a program to print the volume of a cube and the sum of it’s surfaces’ areas Start the program Read the length of the side and save in variable ( Length ) Volume = Length * Length * Length Surface = ( Length * Length ) * 6 Print the variable ( Volume ) Print the variable ( Surface ) End the program Computer Programming -1

Flow Chart Computer Programming -1

Flow chart’s Symbols Start/End End Start Read/Print Print n1 Read n1 Arithmetic Operations N2 = n1+3 N2 = 5 Decision n1 > 3 Loops Connectors arrows Connectors points Comments Java Programming: From Problem Analysis to Program Design, Third Edition // my name

Simple Sequential Flow Charts start End Computer Programming -1

Write a Program to Print the Sum of two integer Numbers start Start the program Read the first number and save in the variable ( N1 ) Read the second number and save in the variable ( N2 ) Sum the both numbers and save the result in the variable ( Sum )  Sum = N1 + N2 Print the variable ( Sum ) End the program Read N1 Read N2 Sum = N1 + N2 Print Sum End Computer Programming -1

Computer Programming -1 Write a program to print the volume of a cube and the sum of it’s surfaces’ areas start Start the program Read the length of the side and save in variable ( Length ) Volume = Length * Length * Length Surface = ( Length * Length ) * 6 Print the variable ( Volume ) Print the variable ( Surface ) End the program Read L Volume = L * L * L ٍSurface = ( L * L ) * 6 Print Volume Print Surface End Computer Programming -1

Write a program to Print the Average of three integer numbers start Read num1 start Read num2 Read num1,num2,num3 Read num3 result = num1+num2+num3 result = num1+num2+num3 Average = result/3 Average = result/3 Print Average Print Average End End Computer Programming -1

Write a program to Print the Average of three integer numbers start Read num1,num2,num3 Average = ( num1+num2+num3 ) / 3 Print Average End Computer Programming -1

Write a program to Print the Average of three integer numbers start start result = num1+num2+num3 Read num3 Read num1 Read num1 Read num2 Read num2 result = num1+num2+num3 Read num3 Average = result/3 Average = result/3 Print Average Print Average End End Computer Programming -1

Write a program to Print the Average of three integer numbers start start Read num1, num2,num3 Read num1, num2,num3 result = num1+num2+num3 Average = result/3 Average = result/3 result = num1+num2+num3 Print result Print Average Print result End End Computer Programming -1

Summery A problem-solving process for programming has five steps: analyze the problem, design an algorithm, implement the algorithm in a programming language, verify that the algorithm works, and maintain the program. An algorithm is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time. A flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. Computer Programming -1