UNIMAP Sem1-08/09EKT120: Computer Programming1 Week 1 – Introduction to Computer and Algorithm.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
EKT 120/4 : Computer Programming
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Introduction to C Programming
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.
CS102 Introduction to Computer Programming
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Spring 2005, Gülcihan Özdemir Dağ Lecture 3, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 3 Outline 3.1 Introduction.
UniMAP Sem2-08/09 DKT121: Fundamental of Computer Programming1 Introduction to C – Part 2.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Computer Organization Six logical units in every.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Introduction to Computer Systems and the Java Programming Language.
UniMAP Sem1-07/08EKT120: Computer Programming1 Week2.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
EKT120: Computer Programming
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
KUKUM Sem1-05/06EKT120: Computer Programming1 Week 2.
UniMAP Sem I – 10/11EKT150: Computer Programming 1 Week 1 – Introduction to Computers and Programming Languages (Part 1) Pn. Rusnida bt. Romli & Che Muhammad.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Introduction to C – Part 1.
Week 1 Introduction to Computers and Programming Languages UniMAP Sem II – 12/13 EKT120: Computer Programming 1.
Lecture 2. Outline Sample programming question Sample C program Identifiers and reserve words Program comments Preprocessor directives Data types and.
WELCOME To ESC101N: Fundamentals of Computing Instructor: Ajai Jain
UniMAP Sem I-09/10EKT150: Computer Programming1 Week 2 – Introduction to Computer and Algorithm.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
UNIMAP Sem2-07/08EKT120: Computer Programming1 Week 2 – Introduction to Programming.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
CC213 Programming Applications Week #2 2 Control Structures Control structures –control the flow of execution in a program or function. Three basic control.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Week 1 – Introduction to Computers and Programming Languages (Part 1)
Week 1 – Session 1 Pn. Yasmin Yacob 04 – KUKUM Sem2-06/07
Chapter 2 - Introduction to C Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Structured Program
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Session 1 – Introduction to Computer and Algorithm (Part 2)‏
Introduction to C Programming
Presentation transcript:

UNIMAP Sem1-08/09EKT120: Computer Programming1 Week 1 – Introduction to Computer and Algorithm

UNIMAP Sem1-08/09EKT120: Computer Programming2 General Information 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

UNIMAP Sem1-08/09EKT120: Computer Programming3 Course Outcomes Understand programming concept and principle. Ability to identify, analyze and produce software program using flowchart and pseudocode. Familiarize with LINUX environment for coding, compiling, executing and debugging computer software program. Obtain logical, creative and innovative thinking skills. Ability to work as a team.

UNIMAP Sem1-08/09EKT120: Computer Programming4 Overall Evaluation 4 main components: Assignments + lab activities (30%)‏ 1st & 2nd Test (15% +25%)‏ Group Mini-project (30%)‏ Assignments are individual “take home” + lab The two tests are written tests Project : Max number of group member is 3

UNIMAP Sem1-08/09EKT120: Computer Programming5 References C How to program, Deitel, Suhizaz, R Badlishah, Yasmin, Pearson Prentice Hall C How To Program 5 th edition”, Deitel and Deitel, Pearson-Prentice Hall,2007 “C Programming for Engineering & Computer Science ”, H.H.Tan and T.B.Orazio, Mc Graw Hill, Any other C programming books

UNIMAP Sem1-08/09EKT120: Computer Programming6 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 Do early reading Do not hesitate to ask during lecture sessions

UNIMAP Sem1-08/09EKT120: Computer Programming7 Outline Computer fundamentals Computer organization and hardware Computer software Programming languages Machine language Assembly language High-level language Algorithm : pseudocode and flowchart Control structures Simple C program

UNIMAP Sem1-08/09EKT120: Computer Programming8 Computer Fundamentals Computer system are divided into hardware and software. Hardware refers to physical components of computers which are: Main memory Central Processing Unit(CPU)‏ Input Device Output Device Secondary memory device

UNIMAP Sem1-08/09EKT120: Computer Programming9 Computer Hardware Input Device Output Device Secondary Memory Control Unit Arithmetic and Logic Unit Register CPU Main Memory

UNIMAP Sem1-08/09EKT120: Computer Programming10 Central Processing Unit(CPU)‏ CPU is the computer’s administrator and is responsible for supervising the operation of the other section Consists of two functional units: a control unit and an arithmetic-logic unit(ALU)‏ Control unit supervises all activities of the computer system ALU perform basic arithmetic operations and comparison operations

UNIMAP Sem1-08/09EKT120: Computer Programming11 Main Memory keeps information from the input unit also keeps processed information until it can be placed on output devices all programs must be loaded into main memory before they can be executed and all data must be brought into main memory before it can be manipulated.

UNIMAP Sem1-08/09EKT120: Computer Programming12 Main Memory Main memory can be further classified into two types: Random Access Memory (RAM)‏ information in RAM will be lost when the computer is turned-off. Read Only Memory (ROM)‏ they have been set during the manufacturing process. ROM usually contains instructions and information considered to be fundamental to the computer.

UNIMAP Sem1-08/09EKT120: Computer Programming13 Secondary Memory Main memory is only used during processing following certain instructions Permanent information is NOT stored in main memory but is stored in secondary memory E.g. program file, data fail etc E.g hard disk, diskette, CD

UNIMAP Sem1-08/09EKT120: Computer Programming14 Input/Output Device Input device - feeds data and programs into computers E.g. keyboard, mouse, touch screen, scanners Output device - display results produced by computer E.g. monitor, printer, speaker

UNIMAP Sem1-08/09EKT120: Computer Programming15 Software As a complement to hardware, computer system needs software to solve problems. Software are classified into : System software Application software

UNIMAP Sem1-08/09EKT120: Computer Programming16 Software System software : manage the computer and its peripheral devices (hardware) E.g. Operating systems(OS)‏ Text editor Preprocessor Language translator Linker Loader

UNIMAP Sem1-08/09EKT120: Computer Programming17 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

UNIMAP Sem1-08/09EKT120: Computer Programming18 Programming Languages Programming language is divided into three categories: Machine Language Assembly Language High-Level Language

UNIMAP Sem1-08/09EKT120: Computer Programming19 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

UNIMAP Sem1-08/09EKT120: Computer Programming20 Assembly Language Strings of 0’s and 1’s are replaced into instructions which resembles English language to represent computer operation element Easier to understand and written E.g LOAD rate MULThour STORwages

UNIMAP Sem1-08/09EKT120: Computer Programming21 Assembly Language Nevertheless, need language translator called Assembler to change Assembly Language to Machine Code for execution purpose still too long and not portable

UNIMAP Sem1-08/09EKT120: Computer Programming22 High-Level Language Improve weaknesses in Machine Language and Assembly Language portable Written in one instruction to carry out several instruction in machine level E.g. discount_price = price – discount; Must be changed to machine code before executed, need compiler : a system software that translate source program to object program

UNIMAP Sem1-08/09EKT120: Computer Programming23 Algorithms The solution to any computing problem involves executing a series of actions in a specific order Pseudocode : artificial and informal language that helps programmers develop algorithms E.g. if student’s grade is greater than or equal to 50 Print “Pass” else Print “Fail”

UNIMAP Sem1-08/09EKT120: Computer Programming24 Algorithms Flowchart: visual-form of an algorithm E.g. Process 2 Decision Data Process 1 Begin End

UNIMAP Sem1-08/09EKT120: Computer Programming25 Algorithm-Basic symbols in a flowchart Start/ End Process Input/Output Decision Flow direction Connector

UNIMAP Sem1-08/09EKT120: Computer Programming26 Flowchart-(E.g)‏ Start read num1, num2 sum=num1+num2 print sum End

UNIMAP Sem1-08/09EKT120: Computer Programming27 TRY THIS!!! Write a pseudocode, flowchart and program that calculate and print the SUM of two integers A and B.

UNIMAP Sem1-08/09EKT120: Computer Programming28 Pseudocode Begin Input A and B Calculate A + B Print results of SUM End Flowchart Begin Input A,B Calculate A + B Prints SUM End

UNIMAP Sem1-08/09EKT120: Computer Programming29 Control Structure All programs could be written in terms of three control structures: Sequence structure Selection structure Repetition structure

UNIMAP Sem1-08/09EKT120: Computer Programming30 Sequence structure Is a series of steps executed sequentially by default Read num1,num2 Calculate total=num1+num2 Print total PseudocodeFlowchart Read num1,num2 total = num1+num2 print total

UNIMAP Sem1-08/09EKT120: Computer Programming31 Selection structure Used to choose among alternative courses of action C has three types: if, if.. else, and switch

UNIMAP Sem1-08/09EKT120: Computer Programming32 The if selection structure if structure is a single-entry/single-exit structure true false grade >= 60 print “Passed” If student’s grade is greater than or equal to 60 Print “Passed”

UNIMAP Sem1-08/09EKT120: Computer Programming33 The if..else selection structure Specifies an action to be performed both when the condition is true and when it is false truefalse print “Failed”print “Passed” grade >= 60 If student’s grade is greater than or equal to 60 Print “Passed” else Print “Failed”

UNIMAP Sem1-08/09EKT120: Computer Programming34 Repetition structure Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied Three types : while, for, do-while

UNIMAP Sem1-08/09EKT120: Computer Programming35 The while repetition structure Programmer specifies an action is to be repeated while some conditions remains true product <= 1000 product = 2 * product true false While product is less than or equal 1000 calculate product=2 * product

UNIMAP Sem1-08/09EKT120: Computer Programming36 Simple C Program //This program will calculate number of RM 50, RM 20, RM 10, RM 5 and RM 1 notes //for a given value entered by user. #include int main(void)‏ { int value, balance; int note50, note20, note10, note5, note1; printf("Enter value in RM : "); scanf("%d",&value); note50 = value / 50; balance = value % 50; note20 = balance /20; balance = balance % 20; note10 = balance / 10; balance = balance % 10; note5 = balance / 5; note1 = balance % 5; printf("Number of RM 50 notes : %d\n", note50); printf("Number of RM 20 notes : %d\n", note20); printf("Number of RM 10 notes : %d\n", note10); printf("Number of RM 5 notes :%d\n", note5); printf("Number of RM 1 notes :%d\n", note1); return 0; }

UNIMAP Sem1-08/09EKT120: Computer Programming37 Basics of a Typical C Program Development Environment

UNIMAP Sem1-08/09EKT120: Computer Programming38 Variables & Reserve Words Variables labels for program elements case sensitive can consists of capital letters[A..Z], small letters[a..z], digit[0..9], and underscore character _ First character MUST be a letter or an underscore No blanks Reserve words cannot be identifiers Reserve words already assigned to a pre-defined meaning eg: delete, int, main, include, double, for, if etc.

UNIMAP Sem1-08/09EKT120: Computer Programming39 Data Types & Mem. Alloc. 1 Boolean representation of logic states. Can only be assigned true (1) or false (0). bool 8 A more precise version of float. Has larger dynamic range and better representation of decimal points. double 4Floating-point number. Set of real numbers. float 4 Integer quantity. Can be represented in signed or unsigned form (with the unsigned keyword). int 1 A single character. Internally stored as a coded integer value (refer to ASCII table ). char Size (bytes) ‏ DescriptionData Type

UNIMAP Sem1-08/09EKT120: Computer Programming40 Type declarations int a; int A; float SUM; float income; float net_income;  int index =0, count =0;  char ch=‘a’, ch2;  const float epf = 0.1, tax = 0.05; float income, net_income; Declare and initialize Named constant declared and initialized

UNIMAP Sem1-08/09EKT120: Computer Programming41 #include int main(void)‏ { int A, B, SUM; printf (“input first integer \n”); scanf (“%d”, &A)‏ printf (“input second integer \n”); scanf (“%d”, &B)‏ SUM = A + B; printf (“Sum is %d\n”, SUM); return 0; } OUTPUT Input first integer 39 Input second integer 27 Sum is 66

UNIMAP Sem1-08/09EKT120: Computer Programming42 End Week 1 – Session 1 Q & A!