Title: Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
1- Theory is when you know something, but it doesn't
work. Practice is when something works, but you
don't know why. - Programmers combine theory and practice Nothing
works and they don't know why. - --unknown
2- Once a new technology starts rolling, if you're
not part of the steamroller, you're part of the
road. - --Stewart Brand
3Nabil Ur Rehman BICSE 3 nabil.rehman_at_niit.edu.pk Zeeshan Ahmad BICSE 3 zeeshan.ahmad_at_niit.edu.pk Jahanzeb Maqbool BIT9-A jahanzeb.maqbool_at_niit.edu.pk Bibrak Qamar BIT9-A bibrak.qamar_at_niit.edu.pk Aqsa Khalid BICSE5A aqsa_khalid_at_yahoo.com
4Introduction to C Programming
5Todays Lecture
- Software Categories
- System Software
- Application Software
- Introduction to C Language
- History
- Evolution
- Justification
- Development Environment of C
6- There are two main categories of software
- System software
- Application Software
7Evolution of programming languages
- The lack of portability between different
computers led to the development of high-level
languagesso called because they permitted a
programmer to ignore many low-level details of
the computer's hardware - Details of procedural, non-procedural will follow
in the lectures
8How people used to program
- Machine Language.. Damn! It was difficult
- Assembly Language. Remember ADD?
- Required too much user involvement
- To much to remember
- Less semantic
- C Language
- B Language.. Bell Labs
- Improved to C Language
- Is a compiled language
9 10Tools of the trade
- Editor
- Interpreter and Compilers
- Debuggers
11Integrated Development Environment(IDE)
- It contains
- Editor
- Compilers
- Debugger
- Linkers
- Loaders
12(No Transcript)
13- include ltiostream.hgt
- main ( )
-
- cout ltlt Welcome to SEECS
14Variable
X
15Variable
- Pic of the memory
- 25
- 10323
-
name of the variable
16Variable
- Variable starts with
- Character
- Underscore _ (Not Recommended)
17Variable
X
18Variable
- Variable is the name of a location in
- the memory
- e.g. x 2
19Variable
- In a program a variable has
- Name
- Type
- Size
- Value
20Assignment Operator
X
2
21Assignment Operator
- L.H.S R.H.S.
- X 3 y 4 Wrong
- Z x 4
- x 4 Z Wrong
2210
X
30
X
23X X 1
X
10
1
11
X
24Data type
i
25Writing C program
26Compiler converts human readable language to a
language which is understandable by the operating
system/hardware Examples of C/C compilers of
today Visual C GCC/G DJGPP (open source for
windows like GCC) Borland C Turbo (obsolete and
not recommended)
273 Stages of Compilation
- Stage 1 Preprocessing
- Performed by a program called the preprocessor
- Modifies the source code (in RAM) according to
preprocessor directives (preprocessor commands)
embedded in the source code - Strips comments and white space from the code
- The source code as stored on disk is not
modified.
283 Stages of Compilation (cont)
- Stage 2 Compilation
- Performed by a program called the compiler
- Translates the preprocessor-modified source code
into object code (machine code) - Checks for syntax errors and warnings
- Saves the object code to a disk file, if
instructed to do so (we will not do this). - If any compiler errors are received, no object
code file will be generated. - An object code file will be generated if only
warnings, not errors, are received.
29Object code
- It is machine language code containing various
calls specific to operating system e.g the
object code written by compiler is not only
hardware dependent but also operating system
dependent. - So if you have linux and windows both operating
systems then object file of compiled by one
Operating System (OS) will not get executed on
the other OS
303 Stages of Compilation (cont)
- Stage 3 Linking
- Combines the program object code with other
object code to produce the executable file. - The other object code can come from the Run-Time
Library, other libraries, or object files that
you have created. - Saves the executable code to a disk file. On the
Linux system, that file is called a.out. - If any linker errors are received, no executable
file will be generated.
31Program Development Using gcc
Editor
Source File pgm.c
Preprocessor
Modified Source Code in RAM
Compiler
Program Object Code File pgm.o
Other Object Code Files (if any)
Linker
Executable File a.out
32 - include ltiostream.hgt //This is pre-processor
directive - void main ( ) //this tells the starting point
of your program -
- int x
- int y
- int z
- x 10
- y 20
- z x y
- cout ltlt " x " //print the text on
monitor - cout ltlt x
- cout ltlt " y "
- cout ltlt y
- cout ltlt " z x y "
- cout ltlt z
-
33- int x, y, z
- int x int y int z