Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.

Description:

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 ... – PowerPoint PPT presentation

Number of Views:244
Avg rating:3.0/5.0
Slides: 34
Provided by: SabaKha
Category:

less

Transcript and Presenter's Notes

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

3
Nabil 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
4
Introduction to C Programming
  • Lecture 2

5
Todays 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

7
Evolution 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

8
How 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
  • ANSI C

10
Tools of the trade
  • Editor
  • Interpreter and Compilers
  • Debuggers

11
Integrated Development Environment(IDE)
  • It contains
  • Editor
  • Compilers
  • Debugger
  • Linkers
  • Loaders

12
(No Transcript)
13
  • include ltiostream.hgt
  • main ( )
  • cout ltlt Welcome to SEECS

14
Variable
X
  • Variable

15
Variable
  • Pic of the memory
  • 25
  • 10323



name of the variable

16
Variable
  • Variable starts with
  • Character
  • Underscore _ (Not Recommended)

17
Variable
  • Small post box

X
18
Variable
  • Variable is the name of a location in
  • the memory
  • e.g. x 2

19
Variable
  • In a program a variable has
  • Name
  • Type
  • Size
  • Value

20
Assignment Operator
  • x 2

X
2
21
Assignment Operator
  • L.H.S R.H.S.
  • X 3 y 4 Wrong
  • Z x 4
  • x 4 Z Wrong

22
10
X
  • X 10
  • X 30

30
X
23
X X 1
X
10
1

11
X
24
Data type

i
  • int i //Declaration line

25
Writing C program
26
Compiler 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)
27
3 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.

28
3 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.

29
Object 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

30
3 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.

31
Program 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
Write a Comment
User Comments (0)
About PowerShow.com