EKT 120/4 : Computer Programming

Slides:



Advertisements
Similar presentations
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
An Overview of Programming Logic and Design
Introduction to a Programming Environment
A High-Level Model For Software Development
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 Program Design
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Chapter 3 Planning Your Solution
PRE-PROGRAMMING PHASE
Introduction to Computers and Programming
Computer Science 101 Introduction to Programming.
CS102 Introduction to Computer Programming
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Simple Program Design Third Edition A Step-by-Step Approach
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
UniMAP Sem1-08/09EKT120: Computer Programming1 Week 1 – Lecture 1.
EKT 120/4 C Programming (Additional note). Computer Fundamentals Computer is a machine that can receive, store, transform an output data of all kinds.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
UNIMAP Sem1-08/09EKT120: Computer Programming1 Week 1 – Introduction to Computer and Algorithm.
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.
Programming Concepts Chapter 3.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
UNIT- I General Problem Solving Concepts
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
EKT120: Computer Programming
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
UniMAP Sem I – 10/11EKT150: Computer Programming 1 Week 1 – Introduction to Computers and Programming Languages (Part 1) Pn. Rusnida bt. Romli & Che Muhammad.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Introduction to C – Part 1.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Week 1 Introduction to Computers and Programming Languages UniMAP Sem II – 12/13 EKT120: Computer Programming 1.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Chapter 1 Introduction 2nd Semester H
Week 1 – Introduction to Computers and Programming Languages (Part 1)
Week 1 – Session 1 Pn. Yasmin Yacob 04 – KUKUM Sem2-06/07
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Unit# 8: Introduction to Computer Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Logic and Design Eighth Edition
Presentation transcript:

EKT 120/4 : Computer Programming By: Mr. Mohd. Nazrin Md. Isa Contact me at : 04-9798410/nazrin@kukum.edu.my

General Information Syllabus – refer handout Contributes 4 units: 2 hours - lectures 4 hours – lab and tutorial Main Objective: Students can independently write a computer program to solve calculation problems, especially those related to engineering

Overall Evaluation 4 main components: Assignments (30%) 1st & 2nd Test (15% +25%) Group Mini-project (30%) Assignments are individual lab The two tests are written tests Project : Max number of group member is 2

References Text Book “ C Programming for Engineering & Computer Science ” H.H.Tan and T.B.Orazio, Mc Graw Hill, 1999. References “C Programming”, Deitel & Deitel “Problem Solving and Programming Concept”, Maureen Sprankle, 6th Ed. Any other C books WWW

Notes This course is NOT about the language per se, it’s about problem solving / analytical skills & to apply C to solve problems. Write C program in Linux environment Please do early reading Do not hesitate to ask during lecture sessions

Outline General Problem Solving Concept The six Steps in Problem Solving Problem Solving Concepts for the Computer Computer Fundamental Data - Constant and Variable Data Type Problem Solving Tool Problem Analysis Chart Structured Chart IPO Chart Algorithm Pseudocode and Flowchart Software System Software Application Software

General Problem Solving Concept People make decisions every day that affect their lives. Problems that we encounter every day may be important or not so important (not so affected to our lives) Generally there are six (6) steps in problem solving. Identify the Problem: What is the problem – in the classroom usually problem is identified for you Understand the problem Identify alternative ways to solve the problem Select the best way to solve the problem List the instruction that enable you yo solve the problem Evaluate the solution

Understand the Problem Understand what is involved in the problem. knowledge base of the person or machine resources. For e.g. if for a person, we must know what the person knows. Different set of instruction need to be given for a different person, depending on the knowledge base. E.g Direction of a place.

Identify Alternative way Identify several way, how to solve the problem, but all this alternative way might suitable to some people but not to some other people. E.g. Direction to KWSP from Jejawi

Select the best way of the alternative solution Here need to identify and evaluate the pros and cons of each possible solution. Thus, we need to identify the criteria for the evaluation as these criteria will serve as a guidelines for the evaluation. E.g. Which is the fastest and shortest way to KWSP from Jejawi.

List the Instructions List down the step-by-step numbered instruction enable to solve the problem using the selected solution. All the instruction should be understand by the targeted person or the machine. E.g 1. go straight 2. Will pass through round about 3. Take 12 o’clock 4. Up further, Until you reach junction with traffic light (where a police station on your right) 5. Take left. 6. You will reach another junction, and take right. 7. Go straight, you will see the KWSP building on your right. 8. Go up further untill you reach a round abou and make U turn 9. Go further until you reach KWSP building End

Evaluate the Solution Check the result: Correct or not. Satisfy the need of the person or not Note: the result may be correct but not satisfy the person E.g The steps you have directed the person might be right, but the person does not drive.

Example – A problem What to do this evening Identify the problem: How do individual wish to spend the evening. Understand The problem: Knowledge base of people involve must be considered So solution selected should be that everyone involved would know haw to do. E.g we select play chess might not possible if the participants does not know how to play chess.

Continue … Identify alternative Watch television, Invite friends over, Play games, go outing. Complete the list until you can’t find any more alternatives. Select the best way to solve the problem Vote out alternatives that are not suitable, such as costly, do not interest one of individual involve etc. Prepare the list of instruction. Evaluate the solution. Everybody satisfy with the solution. Are we having fun? Etc.

Types of Problems Algorithmic Solution – problem can be solved with a series of actions. So once we eliminate the alternatives and have chosen one best methods, these steps are called algorithm. Heuristic Solution – Problem with solutions require reasoning built on knowledge and experience, and a process of trial and error. Ussually use in the Artificial Intelligent software or Expert system softwware.

Problem Solving with Computer Solution means the instructions that must follow to produce the best results. Results mean the outcome or completed computer – assisted answer. Program means the set of instructions that make up the solution after they have been coded into a particular computer language.

Problem Solving Concept with Computer Computer Fundamental CPU – where all the processing take place Memory – store all data currently processed, before program can be execute, program must be loaded into memory Input Device – Device use to input data to be processed into computer Output Device – Device use to display processed data (output) Secondary Memory – Store permanent data (can be as output device. CPU Output Device Input Device Main Memory Secondary Memory

Problem Solving Concept For Computer Problem that can be solve with computers generally consist of three: Computational – problem with mathematical processing Logical – problem involving with relational or logical processing. This is kind of processing involve in decision making. Repetitive – problem involving repeating a set of mathematical or logical instructions.

Constant and Variable (Data) The most fundamental concept of problem solving for computer Computer use constant and variable to solve problem. They are actually the data used in the processing. Constant: Value that never changes during the processing of all the instructions. Can be any type of data – numerical, alphabetical, or special symbols. constant is given a location in memory or a name. During the execution of the instructions (a program) this constant is given a value and then is referred to by its name. Once the constant is given a value it cannot be changed during the execution of the program. Example Pi = 3.14

Continue … Variable: Value of a variable may changed during processing Variable must have a name Programmer uses the variable name as a reference name for a specific value of a variable. the computer uses the name as a reference to access that value in the computer memory

Example Constant And Variable Rule: Cannot be change. Example: Value: Named Constant: Cannot be changed after initially given a value. Storage Loacation has a name Example: Pi Value Rule: Storage lacation given name Values of the content can be change. Refered by name in the instruction. Example Variable Name – Age Variable Name - Name 25 “selamat datang” 20 “Marina” 3.142857

(report/information) Data Types Data is unorganized facts, they go into computer as an input and are processed by the program. The outcome is the output or information in form of report or other meaning full format to the user. data uses are of many different types. We need to tell the computer the type of data for each of the variable used in the program. The most common data types are numerical, character (alphabetical), and logical. Computer Data process into Infomation output input Output (report/information) Data (Unorganized fact)

Data Types Continue … Numerical Data: include all type of numbers. The only data used for calculation. They are integers and real numbers Character Data – Alphanumeric Data Consist of all single digit, letters, and special characters available to the computer, e.g. a to z, A to Z, 3, #, & etc, placed within quotation marks. Uppercase letter is different from the lowercase letter. can be compared and arranged in alphabetical order. Logical consist of two pieces of data in the data set, TRUE and FALSE. There are use in making yes-no decision

Example of Data Types Data Data Type Explanation The price of item: 7.55, 12.99 Numerical: Real Would be use in the calculation An Account Number: “A444440” Character: String Consist of alphanumeric or simply numbers, cannot use in calculation Quantity integer Use in calculation, Integer because normally as a whole number A date: 10/07/06 Date or Character string If date data type is available use date, unless use character string An answer to a question: True / False Logical An answer to question: Do you like coffee, is either yes or no, therefore use logical

Organizing The Problem There are several organizational tool can be used in problem solving Problem Analysis Chart – the beginning analysis of the problem Structured Chart – shows the overall layout or structure of the solution IPO Chart – shows the input, the processing and the output Algorithm is the sequence of instructions comprising the solution Flowcharts is the graphic representations of the algorithm.

Problem Analysis Chart (PAC) Consist of 4 separate parts Section 1 - The given data – Data given or provided by user, can be known value or general name. Section 2 - The required result – Requirement for the output report, information needed and th format required. Section 3 - The processing – List of processing required, include equation or other type of processing, sort, searching and so forth. Section 4 - A list of solution – List of ideas for solution of the problem. Let consider Payroll problem calculating Gross Pay of a worker end of the day. Given Data Required Result Hours Pay Rate Gross Pay Processing Required Solution Alternative Gross Pay = Hours * Pay Rate Define the hours worked and pay rate as constant Define the hours worked and pay rate as input values

Structured Chart Divide the problem into subtasks called modules or smaller subtasks. This breakdown enable you to view complex problems. It only shows you what will happen and not how its happen. Use Top-Down Solution method

IPO (Input-Processing-Output) Chart IPO Extends and organizes the information in the problem analysis chart. Shows more detail what data items are inputs what processing takes place on the data, and what Input Processing Module Reference Number Output All input data (section 1 of PAC) All processing in steps (section 3 & 4 of PAC) Module Reference from structure chart All output requirements (section 1 & 2 from PAC) Input Processing Module Reference Number Output Hours Work Pay rate 1. Enter hours work 2. Enter Pay rate 3. Calculate Pay 4. Print Pay 5. End 1000 2000 3000 0000 Gross Pay

Algorithms Organizing the solution where programmer develop a set of instruction for the computer and this is call algorithm. Pseudo code may be use, it is close to the actual programming language that the programmer will used later. To complete it, the programmer will write another separate set of instruction (coding/program) that will be understand by the computer. Instead of Pseudo code, we can also represent the set of instruction in term of Flowchart ( a graphic presentation of the algorithm.

Algorithm-Basic symbols of flowchart Flowchart Symbol Explanation Flow lines Flow of the direction Start / Stop (terminator) A start and an end of a module. For some end for a main module and exit for other module Processing Processing block, for the calculation, and other step of instructions. Input / Output (I/O) Input and output data to from the computer memory. Decision Usually has one entrance and two exit. Process Module Task that process in different place, module Automatic Counter loop The number of loop execute will start with A, counter incremented by S, and until the end value B Connector on page off page Flowchart can be sectioned, the connector will show where the section continue counter A B S

GrossPay = Hours * Payrate Flowchart-(cont’d) Algorithm Flowchart Main Module 1. Repeat Process Read Process Calc Process Print Until no more employee 2. End Read Module 1000 1. Read Hours, Pay rate 2. Exit Calc Modul 2000 1. GrossPay = Hour * payrate Print Module 3000 1. Print Pay start start Read Read Hours, Payrate Calc Print exit false No more employee True end start start GrossPay = Hours * Payrate Print GrossPay exit exit

Software Software is a program of the solution for a specific task that programmer develop. In computer science software are classified into : System software Application software

Software System software : software manages the computer and its peripheral devices (hardware) E.g. Operating systems(OS) Text editor Preprocessor Language translator Linker Loader

Software Application software : performs specific tasks There are two types: Program to solve specific problems Program written by user to solve specified problem E.g word processor, desktop publishing software, spreadsheets, database, graphics, communication, program perform a specific task such as accounting, scientific, engineering, education etc

Programming Languages Programming language is divided into three categories: Machine Language Assembly Language High-Level Language

Machine Language Language understood by the computer Bunch of 0’s and 1’s Program written in machine language can be executed without being translated Nevertheless, hard to learn because it is written in 0’s and 1’s Program is too long to solve simple problem Machine-dependant and not portable E.g. 0101 1000 0101 1001 1100 0111 0101 0001 1100 0100 1011 1000

Assembly Language It is a low level programming language. To make it easier for the programmer, the strings of 0’s and 1’s are replaced into instructions which resembles English language to represent computer operation element So easier to understand and written E.g LOAD rate MULT hour STOR wages

Assembly Language Nevertheless, need language translator called Assembler to change Assembly Language to Machine Code for execution purpose Assembler is a type of system software, that we use to translate our assembly code into binary code (understand by computer.

High-Level Language E.g. Grosspay := Hourswork * Payrate; Example of high level programming language are, PASCAL, C - Language, Java, Visual Basic etc One instruction of it, consist several instructions in machine level or assembly language. E.g. Grosspay := Hourswork * Payrate; Before it can be executed by computer, the program must be changed to machine code before executed. For high level language compiler will translate the coding into assembly code and binary code. Compiler is a type of system software that we use to compile our C code.

Thank you End of lecture #01 Any questions??? The following exercises are to be completed during lab 1) Exercise 1 2) Exercise 2