Lecture1

Lecture unit 1 ece15 introduction to computer

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: bles ‣ The current running sum (sum) ‣ The current integer value being read (value) ‣ The number of values read so far (i) Note: The algorithm and the data structure do not depend directly on the specific programming language. Lecture Unit 1 ECE15: Introduction to Computer Programming Using the C Language 25 Simple Addition Program: Coding RUN #include <stdio.h> int main() { int i, sum, value; sum = 0; for (i = 0; i < scanf("%d", sum = sum + } printf("%d \n", } return 0; 10; i++) { &value); value; sum); Lecture Unit 1 ECE15: Introduction to Computer Programming Using the C Language 26 From Source Code to Executable source code prog.c Compiler object code prog.obj Linker executable prog.exe other object code other.obj library libc.lib Lecture Unit 1 ECE15: Introduction to Computer Programming Using the C Language 27 Types of Programming Errors Syntax Er rors: such as typos, missing punctuation, or any invalid use of the C language, for example: sum = sum + value; sum = num + value; Syntax errors are immediately found by the compiler. Easy! Run-time Er rors: e.g. division by 0 in a loop; pass the compiler unnoticed, but the program crashes. Also relatively easy. Semantic Er rors: errors in meaning that cause the program to produce incorrect output, for example: Bug! printf("%d \n", sum); printf("%d \n", value); Logical Er rors: in the algorithm itself. Most difficult! Lecture Unit 1 ECE15: Introduction to Computer Programming Using the C Language 28 Outline of this Unit ❖ Computer hardware -- overview ❖ Computer software -- overview ❖ Our very first C programs ❖ Some Relevant Histor y Lecture Unit 1 ECE15: Introduction to Computer Programming Using the C Language 29 The First Computing Device It has all started with the abacus... ‣ Originated in China or the Middle East. ‣ Great improvement as compared to counting using your hands and fingers. ‣ Abacus “remembers” the current state; user controls transit...
View Full Document

Ask a homework question - tutors are online