lecture2 Components of C++

Lecture2 Components - 1 © Janice Regan CMPT 128 Jan 2007 CMPT 128 Introduction to Computing Science for Engineering Students Creating a program

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 © Janice Regan, CMPT 128, Jan. 2007 CMPT 128 Introduction to Computing Science for Engineering Students Creating a program Components of a C++ program © Janice Regan, CMPT 128, Jan 2007 2 Programs in High Level Languages Assembler is easier to read/write than machine language. It is still very cumbersome High level languages are easier to write than assembler The compiler is more complex, but that is a tool you use, not one you write In this course we will learn the language C++ We will use C++ to implement many ideas that can also be implemented in other high level languages © Janice Regan, CMPT 128, Jan 2007 3 Writing your program Editor, Type in your program Source File Text saved on hard disk Compiler Translate text into Machine Readable code © Janice Regan, CMPT 128, Jan 2007 4 Source files Contains the text you type into a text editor The text is a program The program is a list of instructions written in a special Human readable language (C++) The program can be translated, from the Human readable language (in source file) to a machine readable language (in object file), by a compiler A compiler is a special piece of software used to translate from source files to object files © Janice Regan, CMPT 128, Jan 2007 5 Source files Source File: Write using a text editor like the one supplied in Microsoft C++ Do not write your code using a word processor like Microsoft Word. A word processor will save in a special format. The compiler reads only text, not special formats. © Janice Regan, CMPT 128, Jan 2007 6 Perfect Code? Finding Errors 1 It is highly unlikely than any of us will always write perfect code that contains no errors How do we find errors? Are there different kinds of errors? Yes A computer program can contain syntax errors. semantic errors, or logical errors When and how can we detect and correct errors? Compile errors Link errors Run Time Errors © Janice Regan, CMPT 128, Jan 2007 7 Syntax Errors A computer program can contain syntax errors A computer language follows simple rules how words and punctuation of different types may be combined. In English syntax is similar to grammatical structure The compiler for a high level language can detect errors that break those simple rules of syntax (syntax errors) Syntax Errors are usually detected at compile time © Janice Regan, CMPT 128, Jan 2007 8 Semantic Errors A computer program can contain semantic errors Semantics relates to the meaning of the words in a sentence or a computer language command Just like a grammatically correct English sentence can be nonsense, a syntactically correct high level computer language command can also contain semantic errors Some semantic errors may be found by the compiler, some will be found when the program is linked, some may be found at run time © Janice Regan, CMPT 128, Jan 2007 9 Logical Errors When your program completes but gives an unexpected answer it usually means...
View Full Document

This note was uploaded on 05/18/2010 for the course CMPT 128 taught by Professor Regan during the Spring '08 term at Simon Fraser.

Page1 / 42

Lecture2 Components - 1 © Janice Regan CMPT 128 Jan 2007 CMPT 128 Introduction to Computing Science for Engineering Students Creating a program

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online