C as a Programming Language:
- Programming as logic
- Language as grammar and syntax
- Procedural
- Modular
- Abstraction/Hiding
- Object-Oriented
- C++: Parametrization or Generic Programming
Building:
- Generating an executable from code
- Concept of Makefile
Compiling:
- Preprocessing – cpp
- Compiling – gcc
- Some important flags (-o, -c, -Wall, -L, -I, -l, -g, -O, -D, -Wl,)
- Cross compiling
Directives and Include:
- #include
- #define
- #ifdef
- Include guards
- What's in the include?
- Include path “”, <>
General Guidelines
- Maintainability/Readability
- Flexibility/Scalability – Growth and Reduction
- Usability
- Re-usability of Code
Empty Program
- Every statement ends with ;
- Space insensitive
- {} scopes
- A brief intro to functions
- main
Data Types
- Primitive/Built-in data type controls:
- Typical types
- double, float
- int, short, long, long long
- unsigned, unsigned short, unsigned long, unsigned long long
- char, unsigned char – ASCII
- typedef (architecture example)
Variables
- Data Type (Domain)
- Scope – Variables on stack
- Declaration
- Global variables
- Qualifiers
Data Represenation
- Writing constants
- Chars
- printf
- scanf
Operators
- Unary (pre/post++, !, ~, &, *)
- Arithmetic (*,/,%,+,-)
- Bitwise (>>,<<,&,^,|)
- Logical (&&, ||)
- Conditional (? :)
Precedence
- Who gets processed First?
- Primary
- Unary (Right associative)
Casting
- Explicit cast
- Implicit cast
Code Example
//Declaration
int x; char c = 'k';
int x, y;
//Explicit Casting
char x = 'a'; int y = (int) x;
int x = 5; char y = (char) x;
// Implicit cast
double a, b, c; int x; c = a*b + x;
x = a*b + c;