Lecture notes Monday 1/25/99
Dissecting C programs:
- comments:
- between "/*" and "*/"
- for documentation & readability
- ignored by compiler
- functions:
- a program building block
- have a name - e.g. main() - and a body containing statements between "{" and "}"
- every C program begins executing at the function main
- statements:
- one instruction e.g a function call
- end with ";"
- printf() function:
- displays a string of characters given as argument between double quotes
- escape sequences
- part of C Standard Library
- preprocessor directives:
- start with "#"
- "#include" to include header files that help compiler to locate errors
- declaration:
- specify name and types of variables (location in memory)
- before any executable statement
- scanf() function:
- obtain a value from the user
- arguments: format control string between double quotes including conversion specifiers - e.g. %d - and location of variables - e.g. &integer1.
- assignment statement:
- assignment operator "="
- arithmetic operations
- if statement:
- conditional action
- condition between "(" and ")" is built with equality or relational operators
- memory concepts:
- variable: name, type, value
- destructive read-in
- non-destructive read-out
- arithmetic operations
- precedence