C
C
History
Structure
Keywords
Identifiers
Overview
History
C language was developed in 1972 by
Dennis Ritchie and Ken Thompson.
Ritchie was born in 1941, New York. His
father was a prior employee of Bell Labs, a
company he would later spend the rest of
Structure his career with. By 1968, he graduated in Ritchie joined Bell Labs in 1967
Harvard with a degree in physics and and there he met first met long-time
applied mathematics. Kenneth Lane colleague Ken Thompson and
Keywords Thompson was born in 1943, New worked on multiple projects, such as
Orleans. He earned his bachelor’s and UNIX, one of the first portable OS
at the time, B language which
master’s degree in 1965 and 1966 in
Identifiers electrical engineering from the University
would serve as the as a template for
the C programming language, which
of California and would join Bell Labs is the first of a family of languages
soon after. such as C++ and Java.
Overview
History Hea
d e
Unlike otherr programming languages, C is
the only of its kind to be able to handle
Structure low-level language(binary code) while still
accessible to almost all operating systems For their contributions,
even until now. Due to this, C is known as Ritchie and Thompson
Keywords the mother of all modern H e ad
programming as it have moved the industry
er
has all the fundamentals and basic with the development of
structures of programming, while also C and by 1999, were
Identifiers being faster than its predecessors. awarded the U.S.
National Medal of
Technology for their
work on UNIX.
Overview
Hea The header is the first line of the
d er program and calls stored library
History functions with the directive
“#include”. The header files are
determined by the “.h” extension.
For their contributions,
Structure •
Ritchie
The following
Mai•n stdio.h have
– I/O
conio.h – with
areand
the Thompson
different header files:
moved the industry
functions
Console
theI/O functions of
development
• stdlib.h – General Utility functions
•
C and by 1999, were
math.h – Math functions
Keywords Body• string.h – String awarded the U.S.
Functions
t
•
en – Character
ctype.h
• mtime.h – Date
National MedalFunctions
Handling
Technology for
& Time Functions
of
their
e
Identifiers ta• t float.h – Limitswork
S •
of Float Types
on UNIX.
limit.h – Size of Basic Types
• wctype.h – Determines Type of Wide Character Data
rn
tu
Re
Overview While the header is the first line in the
program, the main is the starting /
History entry point of the program and is
Hea necessary
de r as it stores the statements
that the operating system will execute.
Fordeclaration
their contributions,
Main Variable is also done here.
tu rn
Re
Overview
The body is where the statements are written and
History Hea
are enclosed in curly brackets “{}”. All
operations are done in the body. There are 2
d er elements to the body.
For their contributions,
Structure
The highlighted line of code The following are the
Main
is an example of Ritchie
an and Thompson
different type of statements:
have moved the- industry
expression statement, Labeled Statements
with the
“printf” is a function that development of Statements
- Compound
will print the text toCthe
and by 1999, were
- Expression Statements
Keywords Body
screen. awarded the- U.S.
Selection Statements
National Medal of Statements
- Iteration
- Jump
Technology for theirStatements
Identifiers work on UNIX.
n t
e
rn
e m
at tu
St
Re
Overview
The body is where the statements are written and
History Hea
are enclosed in curly brackets “{}”. All
operations are done in the body. There are 2
d er elements to the body.
For their contributions,
History
Structure
Keywords are predefined words that
Keywords have their own meanings, because of
this they can’t be used as a variable
name.
Identifiers
Overview Keywords are predefined
words that have their own
History meanings, because of this
they can’t be used as a
auto double int struct
variable name.
Structure break else long switch
case enum register typedef
char extern return union
Keywords const float short unsigned
continue for signed void
Identifiers default goto sizeof volatile
do if static while
C Storage Classes
These keywords declare different
storage classes:
Overview
auto – Keyword for automatic or
local variables and is available to
History use in the block it’s local to.
auto double int struct extern – Declares external or
global variables and are accessible
Structure break else long switch in any function.
case enum register typedef
char extern return union
Keywords const float short unsigned register – While supposedly
continue for signed void faster than local variables,
Unless you are working on
Identifiers default goto sizeof volatile embedded systems where you
know how to optimize code
do if static while for the given application, there
is no use of register variables.
static – value of this variable
is permanent until the end of
the program.
break – keyword for break
statements that ends loop when
encountered.
Overview continue – keyword for continue
statements that skips the current
iteration of the loop and starts the
History next.
auto double int struct *break and continue statements are
always found in if – else
Structure break else long switch statements.
case enum register typedef
char extern return union
Keywords const float short unsigned
continue for signed void
Identifiers default goto sizeof volatile
do if static while
break – keyword for break
statements that ends loop when
encountered.
Overview continue – keyword for continue
statements that skips the current
iteration of the loop and starts the
History next.
auto double int struct *break and continue statements are
always found in if – else
Structure break else long switch statements.
case enum register typedef
char extern return union
Keywords const float short unsigned
continue for signed void if – keyword for if() statements,
Identifiers default goto sizeof volatile which execute statements in its
body if the expression in the
do if static while parenthesis is true
else – If expression in the if
statement is false, it skips the
statements of the if body and
executes the statements in the body
of else instead.
Switch Statements
History
auto double int struct
History
auto double int struct
History
auto double int struct
History
auto double int struct
History
auto double int struct
History
auto double int struct
Overview
History
auto double int struct
History
auto double int struct
Keywords
Identifiers
Identifiers are names
we give to variables
functions and other
user-defined data
types. There multiple
Overview rules in giving
identifier’s names:
History
Example:
Structure SCS_1101
_SCS_1101
Keywords int char= 20; - A valid identifier can have letters
“NAME”, ”Name”, “name” (both uppercase and lowercase
letters), digits and underscores.
- The first letter of an identifier