0% found this document useful (0 votes)
22 views31 pages

C

C programming language was developed in 1972 by Dennis Ritchie and Ken Thompson at Bell Labs. It combines low-level access to memory with high-level programming features. Ritchie and Thompson's development of C and UNIX operating system moved the industry forward. C became popular due to its portability and ability to access hardware level operations. It has influenced many other programming languages like C++ and Java.

Uploaded by

denzenlastos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views31 pages

C

C programming language was developed in 1972 by Dennis Ritchie and Ken Thompson at Bell Labs. It combines low-level access to memory with high-level programming features. Ritchie and Thompson's development of C and UNIX operating system moved the industry forward. C became popular due to its portability and ability to access hardware level operations. It has influenced many other programming languages like C++ and Java.

Uploaded by

denzenlastos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Overview

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.

Structure Ritchie and Thompson


have moved the industry
There arewith the development
3 different types of main of functions:
C and
1. Main Function w/oby 1999, were
Arguments & void return type
Keywords Body
2. Main Function w/o awarded
Argumentsthe U.S.
& int return type – Returns
e nt value National Medal
as 0 if there areofno errors.
3.mMain Function
Technology
w/ Commandfor their
Line Arguments –
t e
Identifiers ta it is possible work
While
S
to use ontheUNIX.
void return type, it is not the
standard and can sometimes lead to unexpected errors, so it is
expected to use the int return type over void.
turn
Re
Overview
The body is where the statements are
History Hea written and are enclosed in curly
de r
brackets “{}”. All operations are done
in the body. There
For their are 2 elements to
contributions,

Structure Main Ritchiethe


andbody.
Thompson
have moved the industry
with the development of
C and by 1999, were
Keywords Body awarded the U.S.
n t National Medal of
m e Technology for their
at e
Identifiers St work on UNIX.

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,

Structure Main Ritchie and Thompson


have
To be moved the industry
able to finish the main
with the we
function, development
include the of
C andstatement
return by 1999,atwere
the
Keywords Body end, awarded
returning the
values
U.S.of the

n t program and ending


National Medaltheof
m e main() function.
Technology for their
Identifiers at e work on UNIX.
rnSt
tu
Re
Overview

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

switch – Keyword for switch


statements; Enables users to single
Overview out a block code out of many and
execute it.
case – If the expression matches a
History case, it executes its statements
auto double int struct until the break.
default –default statements are
Structure break else long switch usually found after the cases and is
case enum register typedef executed after there is no match
between cases and expression.
char extern return union
Keywords const float short unsigned
continue for signed void
Identifiers default goto sizeof volatile
do if static while
Data Types-
Specifies the type of information
stored in a variable. The following
Overview are basic data types:
int – Stores whole numbers,
without decimals
History float – Stores fractional numbers,
auto double int struct containing one or more decimals.
Sufficient for storing 6-7 decimal
Structure break else long switch
digits
case enum register typedef
char extern return union
Keywords const float short unsigned
continue for signed void
Identifiers default goto sizeof volatile
double - Stores fractional
numbers, containing one or more
do if static while decimals. Sufficient for storing 15
decimal digits
char – Stores a single
character/letter/number, or ASCII
values
Overview const – placed next to a variable
which specifies that variable’s
History value cannot be changed.
auto double int struct

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
do – while loops
A type of loop that executes the
body first and executes the body
Overview again until the expression is false.
do – Keyword for do statement
while – Stores expression
History
auto double int struct

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
enum – enum or enumeration is a
data type that stores a a list of
constants with integer values.
Overview

History
auto double int struct

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
for loops
A type of loop that executes the
initialization statement once and
Overview executes the body and updates the
expression. It loops until the
expression is false.
History for – Keyword for for loop.
auto double int struct

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
goto – Keyword for goto
statements; used to jump from
anywhere within a function. It can
Overview be useful in breaking from loops.

History
auto double int struct

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
The following are type modifiers
that change the range of the data
type.
Overview short – Has a shorter range in
favor of memory.
long – Has a wider range but takes
History up more memory.
auto double int struct signed – Accept both positive and
negative values.
Structure break else long switch
unsigned – Integers can never be
case enum register typedef negative.

char extern return union


Keywords const float short unsigned
continue for signed void
Identifiers default goto sizeof volatile
do if static while
return – returns a value where the
function was called and terminates
the functions.
Overview

History
auto double int struct

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
sizeof – Operator that returns the
size of the data, (int=4, float=4,
double=8, char=1).
Overview

History
auto double int struct

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
struct – Keyword for declaring a
structure; holds multiple variables
inside of it.
Overview

History
auto double int struct

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
typedef – Used to change the
name of a data type for the
program.
Overview

History
auto double int struct

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
union – Data type that holds
multiple variables. Unlike
structure, all members share the
Overview same memory and can only hold
one value.
History
auto double int struct

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
void – Has no value / NULL value,
therefore there is no return value.

Overview

History
auto double int struct

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
volatile – Creates volatile objects;
objects that can be changed by
hardware and are omitted from
Overview optimization.

History
auto double int struct

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
Overview

History Identifiers are names we give to


variables functions and other user-
defined data types. There multiple
Structure rules in giving identifier’s names:

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

Identifiers should be either a letter or an


underscore.
- You cannot use keywords like
int, while etc. as identifiers.
- There is no rule on how long an
identifier can be. However, you
may run into problems in some
compilers if the identifier is longer
than 31 characters.
- The identifier must be unique

You might also like