Академический Документы
Профессиональный Документы
Культура Документы
1
Computer Software: Languages Machine language
• Some Computer Languages • Each type of processor (like Pentium 4,
– Machine language (machine instruction set) Athalon, Z80, …) has its own instruction set
– assembly language • Each instruction in an instruction set does a
– high level languages single thing like access a piece of data, add two
– C, C++, Ada, Fortran, Basic, Java pieces of data, compare two pieces of data …
• Each instruction is represented by a unique
• Do YOU know of any others? number This # may be different for different
– mathematical computation tools (MATLAB, instruction sets, but no two instructions in the
Mathematica, ...) same instruction set will have the same #
9 10
11 12
2
History of C C Standard Library
• C evolved from two previous languages • C program consists of modules or pieces called
– BCPL in 1967 by Martin Richards functions.
– B in 1970 by Ken Thompson • The C Standard Library contains a extensive
• From B, Dennis Ritchie developed C at Bell collection of functions to form a C program.
Laboratories in 1972. • In creating a program in C, usually, you would use
– Today, virtually all Operating Systems are developed the following:
using the C language, or the C++. – The C Standard Library functions
– Functions you create yourself
– Functions others have created, and are now available
for you
13 14
15 16
17 18
3
Syntax Errors Semantic Errors
• A computer program can contain syntax errors • A computer program can contain semantic
• A computer language follows simple rules errors
– how words and punctuation of different types may be • Semantics relates to the meaning of the words
combined. in a sentence or a computer language command
– In English syntax is similar to grammatical structure – Just like a grammatically correct English sentence can
• The compiler for a high level language can be nonsense, a syntactically correct high level
detect errors that break those simple of syntax computer language command can also contain
semantic errors
(syntax errors)
• Some semantic errors may be found by the
• Syntax Errors are usually detected at compile
compiler, some will be found when the program is
time
linked, some may be found at run time
19 20
Summary:
Perfect Code? Finding Errors 3
Executing a Computer Program
• If your code compiles and contains no errors • Compiler
that can be found by the linker (or splint) is it – Converts a source file (containing your human readable
correct? NOT NECESSARILY program in C) to and object file (computer readable
binary file)
• How do we find the remaining logic and
semantic errors? • Linker
– When you run your executable program it may not – Converts object program to executable program
complete (may or may not generate error message)
– It may complete and give the wrong answer
23 24
4
Summary: Types of Errors
• Syntax errors
– Errors in syntax, how words are combined and used
reported by the compiler or splint
Introduction to
• Semantic errors
– Errors in the meaning of words, Scientific
– Reported by the linker (linker errors) Computer Programming
– Reported by the compiler (compile time errors)
– Found at execution time (run-time errors) – Computer Concepts
• Logic errors and C
– Errors causing the incorrect results, not reported
– Errors causing program failure (run-time errors)
25