CS1061 C Programming Lecture 3: The Programming Environment + Introduction to the Concept of an Algorithm A. O’Riordan, 2004.

Slides:



Advertisements
Similar presentations
Introduction to Programming Lecture 2. Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application.
Advertisements

Systems Software.
Programming Types of Testing.
CS105 INTRODUCTION TO COMPUTER CONCEPTS INTRO TO PROGRAMMING Instructor: Cuong (Charlie) Pham.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
COSC 120 Computer Programming
CS2200 Software Development Lecture 2: Java Program Development Lecturer: Adrian O’Riordan Course Webpage:
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.
COMP205 Comparative Programming Languages Part 1: Introduction to programming languages Lecture 3: Managing and reducing complexity, program processing.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
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.
CSC141 Introduction to Computer Programming
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
CPS120 Introduction to Computer Science Iteration (Looping)
Introduction to Programming Lecture No. 1. Books  Deitel & Deitel :– C++ How to Program  Kernighan and Ritchie:- The C Programming Language.
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.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
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.
Errors “Computer says no..”. Types of Errors Many different types of errors new ones are being invented every day by industrious programming students..
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.
Typical C++ Environment and Library Introduction Speaker : Wei-Lu Lin Advisor : Ku-Yaw Chang 2012/10/14.
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.
CPS120 Introduction to Computer Science Iteration (Looping)
CS-303 Introduction to Programming
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
Introduction to OOP CPS235: Introduction.
The Hashemite University Computer Engineering Department
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
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.
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Chapter 1 Introduction 2nd Semester H
DDC 2223 SYSTEM SOFTWARE DDC2223 SYSTEM SOFTWARE.
Advanced Computer Systems
Visit for more Learning Resources
Programming Languages
CSC201: Computer Programming
ALGORITHMS AND FLOWCHARTS
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
CS105 Introduction to Computer Concepts Intro to programming
Programming Fundamentals Lecture #3 Overview of 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.
Introduction to Computer Programming
PROGRAM AT RUNTIME Subject code: CSCI-620
Chapter 1 Introduction to Programming
Chapter 15 Debugging.
CS105 Introduction to Computer Concepts Intro to programming
Chapter 15 Debugging.
Presentation transcript:

CS1061 C Programming Lecture 3: The Programming Environment + Introduction to the Concept of an Algorithm A. O’Riordan, 2004

The Programming Environment Initially, a programmer writes a program in the C programming language. This form of the program is called the source program, or source code. A program can be written in one or more files. C has a pre-processor which modifies souce code (so-called directives trigger the preprocessor). The compiler translates the source code into a form called object code. (This will take a few moments.) a linker is a program that combines object files to form an executable program. Library routines are also “linked in.” Now an execuable is produced which can be run.

Phases of Program Construction Initially the program requirements need to be defined clearly and the program designed. Then programming begins. Phases of C Program Construction: Edit Preprocess Compile Link and Load (into memory) Execute This is a iterative process while the program is in development.

Compilation Process f1.cf2.c f2.of1.o prog.exe f3.c pre-processor compiler linker Library

Editing and Debugging Source code in written using an editor (simplied word processor suitable for programming). typical functionality includes cut-and-paste, go to line number, find and replace, etc. A special program called a debugger can used to find errors (bugs). A debugger allows a programmer to stop a program at any point and examine and change the values of variables. An error or defect in software that causes a program to malfunction.

Compiler Messages A compiler warning indicates you've done something “dangerous”, but will not prevent the code from being compiled. You should fix whatever causes warnings since they often lead to other problems that will not be so easy to find. A compiler error indicates something that must be fixed before the code can be compiled. Example: You forget a semi-colon ( ; ) at the end of a statement fix the first few errors since they may be causing all the rest.

Linker and Run-time errors If you receive a linker error, it means that your code compiles fine, but that some function or library that is needed cannot be found. Run-time errors only occur when you run a program, i.e. executable crashes. example: trying to divide by zero int scores = 500, num = 0, avg; avg = scores / num; example: memory error (segmentation fault) These occur when you try to access memory that your program is not allowed to use or that doesn't exist

concept of an Algorithm A formula or set of steps for solving a particular problem. For example, a recipe for baking a cake is an algorithm. Programming examples include: sorting a list of names searching for a record in a file record. Mathematics has many such procedures that are implemented as an algorithm: identify all prime numbers up to a given number n (Sieve of Eratosthenes) The word algorithm in English comes from the Arab mathematician al- Khowarizmi who flourished at the end of the 8th Century A.D.

Sieve of Eratosthenes 1. Write down the numbers 1, 2, 3,..., n. We will eliminate composites by marking them. Initially all numbers are unmarked. 2. Mark the number 1 as special (it is neither prime nor composite). 3. Set k=1. Until k exceeds or equals the square root of n do this: 1. Find the first number in the list greater than k that has not been identified as composite. (The very first number so found is 2.) Call it m. Mark the numbers 2m, 3m, 4m,... as composite. 2. m is a prime number. Put it on your list. 3. Set k=m and repeat. 4. The list gives all the primes less than n.

Algorithms in Engineering Engineers have many well-known algorithms for various problems. Solving Linear Equations - e.g. Gaussian Elimination Optimization - For a function A function f(x_1,...,x_n), what point p = (p_z,...,p_n) maximizes (or equivalently minimizes) the function f? Job scheduling - e.g. first in first out (FIFO) Transportation Problems - Vehicle Routing, “Travelling Salesman”, Network Flow Circuit Layout etc.