Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction
C: History
Developed in the 1970s in conjunction with development of UNIX
operating system
When writing an OS kernel, efficiency is crucial
This requires low-level access to the underlying hardware:
e.g. programmer can leverage knowledge of how data is laid out in memory, to
enable faster data access
2
C: Characteristics
C takes a middle path between low-level assembly language
Direct access to memory layout through pointer manipulation
Concise syntax, small set of keywords
and a high-level programming language like Java:
Block structure
Some encapsulation of code, via functions
Type checking (pretty weak)
3
C: Dangers
C is not object oriented!
Cant hide data as private or protected fields
You can follow standards to write C code that looks object-oriented, but you
have to be disciplined will the other people working on your code also be
disciplined?
4
Basic Data Types
5
Basic Data Types
6
Boolean in C
#define TRUE 1
#define FALSE 0
7
Expression
8
Expression
9
Expression
10
I/O BASIC
%d" (for integer)
11
If Else
12
Loop (for)
13
Loop (while)
14
Loop (doWhile)
Loop ( Break and Continue)
Switch Case
Function
How it works ?
18
Argument, Return Value, Variable
argument
Return Value
19
Function
20
Function
21
EXERCISE
22
Exercise Hello World !
23
Exercise Flow Control
24
Exercise - Reverse Number
25