CSC141 Introduction to Computer Programming

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

EC-111 Algorithms & Computing Lecture #1 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
PROBLEM SOLVING TECHNIQUES
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Introduction to Programming Lecture 2. Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Three types of computer languages
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
ALGORITHMS AND FLOWCHARTS
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
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.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Programming Lifecycle
1 Problem Solving with C++ The Object of Programming Walter Savitch Chapter 1 Introduction to Computers and C++ Programming Slides by David B. Teague,
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
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.
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.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
CS-303 Introduction to Programming
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Introduction to C – Part 1.
1 Overview of Programming Principles of Computers.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
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.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Program Program is a collection of instructions that will perform some task.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Chapter 1 Introduction 2nd Semester H
GC101 Introduction to computers and programs
Introduction to Programming / chapter 3 / COM1022
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
Computer Programming.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 2 Introduction to Programming
ALGORITHMS AND FLOWCHARTS
Chapter 1 Pseudocode & Flowcharts
Programming Fundamentals (750113) Ch1. Problem Solving
ALGORITHMS AND FLOWCHARTS
Chapter 1 Pseudocode & Flowcharts
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
Introduction to Computer Programming
Introduction to Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Computer Programming-1 CSC 111
Chapter 1 Introduction to Programming
Chapter 1 Pseudocode & Flowcharts
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 3

Problem Solving and Implementation A programming task can be divided into two phases: 1. Problem solving Define : Clearly describe a problem Design its solution: Produce an ordered sequence of steps that describe solution to the problem; 2. Implementation phase Implement the program in some programming language write code, compile, link, Test & Debug

Developing a program Problem solving Phase Implementation phase

Defining a Problem: Break the definition of the problem down into manageable steps. Example; input, Processing; Output Input ; Read the temperature from keyboard Processing; Test the Temperature below or above freezing Output; Display the result on Screen Users: Identify the users. Feasibility & Implementation.

Design the solution Algorithm A sequence of language independent steps which may be followed to solve a problem. An Algorithm can be developed with a: Pseudo Code Flowchart Preferably using control Structures.

Algorithm Pseudo code Pseudo code is a method of designing a program using English like statement to describe the logic and processing flow. There are no real rules; organizations follow their own standards. Conveniently understood and exchanged between IT professionals.

Defining a Problem: Break the definition of the problem down into manageable steps; Input, Processing; Output Example -1: Read in the temperature. If the temperature is less than 32 indicate below freezing on the screen. Else if the temperature is above freezing then indicate the same on the monitor screen. Divide the above problem into manageable parts. Input ; Read the temperature from keyboard Processing; Test the Temperature below or above freezing Output; Display the result on Screen

Algorithm Pseudo code Example -1: Read the Temp if (Temp < 32) then Print “BELOW FREEZING” else Print “ABOVE FREEZING” endif

Algorithm Flowchart Diagrammatic or Graphical representations of steps for solving the given problem. Use standard symbols developed by ANSI (American National Standard Institute)

Building Blocks of Flowchart Start and End Symbols Connector Arrows (indicate flow of control) Processing Steps Input/Output Decision CSC 141 Introduction to computer programming

Defining a Problem: Break the definition of the problem down into manageable steps; Input, Processing; Output Example -1: Read in the temperature. If the temperature is less than 32 indicate below freezing on the screen. Else if the temperature is above freezing then indicate the same on the monitor screen. Divide the above problem into manageable parts. Input ; Read the temperature from keyboard Processing; Test the Temperature below or above freezing Output; Display the result on Screen

CSC 141 Introduction to computer programming Define The Problem Example-2; Determine the sum of first 50 natural numbers. Break into steps Input – Nil Processing: Sum the numbers from 1 to 50 Output - Sum CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Design the Solution Example-2; Determine the sum of first 50 natural numbers. Algorithm; Pseudo Code 1. Set N=1 Set Sum = 0 2. Repeat step 3 & 4 while N <= 50 3. Sum = Sum + N 4. N = N + 1 5. Print Sum 6. end CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Design the Solution Example-2; Determine the sum of first 50 natural numbers. Algorithm; Flow Chart Start End Sum=0 N=1 N≤50 Y Print Sum Sum=Sum+N N=N+1 N CSC 141 Introduction to computer programming

Example-3: Determine the factorial of input number CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Define The Problem Example-3; Determine the factorial of input number. Break into steps Input – Number is N Processing: Factorial = N x N-1 x N-2 x N-3 ……. 3 x 2 x 1 Output - Factorial CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Design the Solution Example-3; Determine the factorial of an input number. (assume number is positive) Algorithm; Pseudo Code 1. Set Factorial = 1 2. Read N from keyboard 3. if ( N = 0 ) goto step 6 4. Factorial = Factorial x N 5. N = N – 1 ; goto step 3 6. Print Factorial 5. end CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Design the Solution Determine the factorial of an input number. Algorithm; Flowchart Start End Fact =1 N = 0 N Y Fact =Fact *N N=N-1 Print Fact Read N CSC 141 Introduction to computer programming

Control Structure: Definition; A control structure or logic structure is a structure that controls the logical sequence in which the instructions are executed. Three types of control structure are used: Sequence Selection Iteration ( or loop)

Developing a program Problem solving Phase Implementation phase

CSC 141 Introduction to computer programming Implementation Phase Write a program (source code) Compile a program (source code to Object code) Link a Program ( Object code to Executable code) Test and Debug the Program (rectify the errors in the program) CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Write a code Create a source code we need an editor Line editor --- line by line editing Screen editor --- note pad, word pad, customized editor After writing the code we save the code with file extension e.g .c .cpp CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Compile a program source code to Object code We need a compiler e.g FORTRAN, PASCAL or C It converts user readable code to machine readable code Cannot be executed because different sections are not mapped together, say not linked together CSC 141 Introduction to computer programming

CSC 141 Introduction to computer programming Link a Program Object code to executable code first.obj to first.exe Can be executed because different sections are mapped together. Execute the code by simply typing the name of file first.exe or even first CSC 141 Introduction to computer programming

Test and Debug the program Rectifying logical errors in the code, manually or may Use debugger for the assistance. A debugger may: Execute the code line by line or block by block or in one go Examine the contents of variables and registers at each step Examining the flow of control structure by tracing code step by step. CSC 141 Introduction to computer programming

Program Execution Two ways: 1. Use command prompt e.g DOS or UNIX command prompt 2. Use Integrated Development Environment

Command prompt

Integrated Development Environment (IDE) 1. A source code editor 2. A compiler and / or an interpreter 3. Build automation tools 4. A Debugger Compiler – translates complete code in one go Interpreter –translates code one line at a time

Typical C environment Program is created in the editor and stored Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, and store new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker link the libraries with object code performs address calculations map the variables and produces the .exe file Editor Preprocessor Linker   CPU . Disk