lecture_03 - ECE 190 Lecture 03 January 25, 2011...

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

View Full Document Right Arrow Icon
ECE 190 Lecture 03 January 25, 2011 1 V. Kindratenko Introduction to C Lecture Topics Introduction to C Variables in C Operators, expressions, statements Basic I/O with printf and scanf Lecture materials Textbook Chapter 11, § 12.1., 12.2 Homework None Machine problem None
Background image of page 1

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

View Full DocumentRight Arrow Icon
ECE 190 Lecture 03 January 25, 2011 2 V. Kindratenko Introduction to C Overview C language was invented in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system o Was standardized in 1988, the standard is called ANSI C (for American National Standards Institute) o In 1990, the ANSI C standard with some minor modifications was adopted by the International Organization for Standardization. This version is called C90 o The latest standard is called C99, it was adopted in 2000 by ANSI from ISO o In this course we will study ANSI C C is a general-purpose high-level computer programming language o Provides an abstraction of the underlying hardware o Is independent of ISA o Is expressive , meaning that complex tasks can be expressed with a small amount of code o Is much more readable than assembly code symbolic names are used instead of memory locations and registers to refer to values operators are used to manipulate values but note that some operators are taken directly from the assembly language, e.g. ++ C is a procedural language o the programmer specifies an explicit sequence of steps to follow to produce a result o the program is composed of procedures, also called a function, or routine, or subroutine C programs are compiled rather that interpreted o Compiler translates a program written in C into machine code that is directly executable by the processor for which it is compiled o For comparison, interpreted programs are executed by another program, called interpreted. They are not translated into binary instructions Basic C program structure Consider the following C program example: /* my first program written in C; it prints the value of PI and exits */ #include <stdio.h> #define PI 3.1416f int main() { float pi = PI; printf(“pi=%f\n”, pi); return 0; }
Background image of page 2
ECE 190 Lecture 03 January 25, 2011 3 V. Kindratenko Comments o /* this is a comment. All text including carriage returns is not considered to be text to be compiled until the terminating symbol is reached, that being */ pre-processor directives begin with # o #include <stdio.h> Instructs the pre-processor to copy content of stdio.h (header file) into the source code stdio.h header file includes function declarations necessary to use standard I/O functions in C almost all programs will need to include this header file other examples of include files are math.h, stdlib.h, etc. <stdio.h> and other header files included in <> are located in some well-defined
Background image of page 3

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

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

Page1 / 8

lecture_03 - ECE 190 Lecture 03 January 25, 2011...

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

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