1b - Introduction to Programming in C
1b - Introduction to Programming in C
IN C
06/01/2025 1
OUTLINE
Definitions of Terms
Programming Paradigms
Compiler Terminology
Errors
C Language
Programming Character Set
06/01/2025 2
PROGRAMS
06/01/2025 6
ARE ALL PROGRAMS WRITTEN THE SAME
WAY?
NO
Different languages (means different ways of
translating hence different translators)
Different syntax (i.e. Grammar and
punctuation)
Different functionalities achievable
Some more complex than others
06/01/2025 7
SO LET’S BEGIN!
06/01/2025 8
WHAT IS AN ALGORITHM?
An algorithm is a
Series of STEPS which when followed achieve a
TASK
It is much like a recipe
Transformati
ingredients on steps results
Transformati
input output
on steps
06/01/2025 9
PROGRAMMING
Telling the computer what to do
Giving instructions in a language understood by
the computer
Instructions follow the algorithm
Instructions are a formal writing of the algorithm
Program = Complete set of formal
instructions
For accurate, expected results, Instructions must be
Precise
Unambiguous 06/01/2025 10
ACHIEVING ACCURATE RESULTS
? Which
Ingredients
? In what form
? What Process
? What Output
? In what form
06/01/2025 12
DISCUSSION 2 – COMMENT ON THE RICE
ALGORITHMS
Points to note:
Algorithms are NOT specific
in measures of ingredients
on where or how the ingredients are stored,
on utensils to be used,
on size of utensils to be used
on time , time varies per group and per exposure
Results
Inaccurate (too much rice or too little rice)
Inconsistent (raw rice or overcooked rice)
06/01/2025 13
DISCUSSION 3 – SO WHAT ARE REQUIRED
CHARACTERISTICS OF PROGRAMS
06/01/2025 14
SIMPLE PROGRAMMING MODEL
Cook Rice.
• What is
required
before we steps
start • What are the
actually • What steps
do we carry results of the
cooking the
out in the steps we
rice?
cooking of carried out?
the rice?
outp
input ut
06/01/2025 15
REAL PROGRAMMING MODEL
Inpu
t
Computer
machine has
data
step Programming =
s writing code
to manipulate
data
outp
ut
06/01/2025 16
DISCUSSION 4 (3 MINUTES)
Give an algorithm to do two things:
varied interpretations
DIFFERENT APPROACHES TO PROGRAMMING
Programming Paradigm:
way of conceptualising what it means to perform
computation and how tasks to be carried out on a
computer should be structured and organised
1. Imperative:
how-to, algorithm explicit, goal implicit, use of functions
e.g. procedural programming, Fotran, C, C++,
functional programming (such as Haskell)
2. Declarative:
what-is, goal explicit, algorithm implicit, use of logical
expressions e.g. Prolog
06/01/2025 18
3. Object-oriented:
which objects , who? e.g. Smalltalk, C++, Java
PROCEDURAL PROGRAMMING
Procedural programming is a programming
paradigm built around the idea that
programs are sequences of instructions to
be executed. They focus heavily on splitting up
programs into named sets of instructions called
procedures, analogous to functions. A procedure
can store local data that is not accessible from
outside the procedure's scope and can also access
and modify global data variables.
Creating
that now Executable Code
RUNs on (invoked by user
Computer to see if it
works)
06/01/2025 20
MORE ABOUT THE COMPILER
Produce object
file not yet
Source 1. Compiler:
linked to other
program file Check syntax
invoked
(.c) errors
libraries
(.obj, .o)
Run 2. Linker:
Build final
executable file combine all
executable file
and detect object files
(.exe)
runtime errors with libraries
06/01/2025 21
ERRORS ENCOUNTERED WHEN
PROGRAMMING
06/01/2025 22
SKILLS REQUIRED FROM YOU IN
PROGRAMMING
Attention to detail
Specific
Unambiguous
Knowing the computer is stupid
Until you give it instructions.
It will do exactly as you tell it to.
Good memory
Of syntax, defined names, names of prewritten functions
Ability to think on several levels
Compartmentalise into little box processes which perform23
06/01/2025
useful tasks
NOW LET’S TALK ABOUT C LANGUAGE
Compact language
Powerful (especially for efficient machine-
dependent programming)
Not as heavy as industrial-type languages
like Php, Java
Syntax heavily influenced industrial-type
languages
One of the best teaching languages.
06/01/2025 24
C LANGUAGE SPECIFICS
Case-sensitive