Errors “Computer says no..”. Types of Errors Many different types of errors new ones are being invented every day by industrious programming students..

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Chapter 5 Errors Bjarne Stroustrup
Introduction to C Programming
Topics Introduction Types of Errors Exceptions Exception Handling
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
CSCE 121: Introduction to Program Design and Concepts Dr. J. Michael Moore Spring 2015 Set 7: Errors 1 Based on slides created by Bjarne Stroustrup.
Programming Types of Testing.
CS16 Week 2 Part 2 Kyle Dewey. Overview Type coercion and casting More on assignment Pre/post increment/decrement scanf Constants Math library Errors.
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.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
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.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
Week 3 Part I Kyle Dewey. Overview Odds & Ends Constants Errors Functions Expressions versus statements.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
ERROR HANDLING Lecture on 27/08/2013 PPT: 11CS10037 SAHIL ARORA.
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.
COP4020 Programming Languages
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
General Programming Introduction to Computing Science and Programming I.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Programming Lifecycle
Program Development Life Cycle (PDLC)
Java Chapter 1 Problem solving: 1. Understanding the problem. 2. Breaking the problem into manageable pieces. 3. Designing a solution. 4. Considering alternatives.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Exception Handling Unit-6. Introduction An exception is a problem that arises during the execution of a program. An exception can occur for many different.
Decisions in Python Bools and simple if statements.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
Basic Programming Lingo. A program is also known as a  Sequence of instructions  Application  App  Binary  Executable.
2. Program Development Intro Programming in C++ Computer Science Dept Va Tech August 2001 ©2001 Barnette ND & McQuain WD 1 Top-Down Design:A solution method.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
ERRORS. Types of errors: Syntax errors Logical errors.
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
LECTURE 3 Compiler Phases. COMPILER PHASES Compilation of a program proceeds through a fixed series of phases.  Each phase uses an (intermediate) form.
C language + The Preprocessor. + Introduction The preprocessor is a program that processes that source code before it passes through the compiler. It.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Software Engineering Algorithms, Compilers, & Lifecycle.
User-Written Functions
ME 142 Engineering Computation I
C is readable... :-) What does this function do?
Component 1.6.
CSC201: Computer Programming
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
Common C Programming Errors, GDB Debugging
Detecting and Resolving Model Errors
Creating your first C program
Programming Errors Key Revision Points.
Programming.
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Learning Intention I will learn about the different types of programming errors.
Review of Previous Lesson
WJEC GCSE Computer Science
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Errors “Computer says no..”

Types of Errors Many different types of errors new ones are being invented every day by industrious programming students.. Three general categories: compile-time errors linker errors runtime errors Compiler errors are significantly easier to detect and fix, since the compiler tells you what they are and where to find them!

Compiler Errors Compiler is just another program, and requires input in the right format 3 classes of compile time errors: lexical errors: ‘words’ cannot be determined syntax errors: ‘grammar’ is incorrect semantic errors: doesn’t make sense! These types of errors are almost identical to those encountered in spoken and written languages..

Lexical Errors Compilers work by breaking the source file into tokens when this cannot be done, a lexical error occurs English equivalent: misspelling words, nonsense words, incorrect spacing, etc.. “Thw3#5-ta_lbe ishcy+3i#%!” C example: whilea<130printf(“hello”);

Syntax Errors Most common form of compile error Correct grammar of the language has not been applied: no semicolon at end of statement no matching ( ), [ ], or { } incorrect structure of if, while, for statements, etc incorrect number of arguments for operators English example: “The dog brown the fence underneath dug” C example: for ( i = 14 ; i++ ){ printf ( “%d”, i )

Semantic Errors Syntax is correct, but meaning of statements makes no sense incorrect argument types incorrect LHS parameters to certain operators C is considerably less strict on semantics than other languages this is a BAD thing for beginner programmers as mistakes are not flagged by the compiler even though they make little sense.. C examples: int a = 14 ; 7 = a ; printf ( a ) ;

Linker Errors The C compiler trusts the programmer if they say a function will be available, the compiler assumes it will be and operates as such sometimes warnings will be generated, sometimes not.. The linker however requires that all such functions actually do exist if they do not, errors are generated by the linker these are very different in appearance to compiler errors, and generally are of the form: undefined reference to ‘???????’ Can often be fixed by including the correct library or object file, or fixing spelling mistakes in your code

Runtime Errors These errors occur after compilation, when the program is running They can either: crash the system cause incorrect behaviour The second type are known as ‘logical errors’

Runtime Errors Typical examples: division by zero accessing invalid memory English equivalent: “Stand up. Lift left leg. Lift right leg.” Logical errors: anything that isn’t correct!!