lecture2

Document Sample
lecture2 Powered By Docstoc
					      Introduction …


           Languages, Algorithms, Flowcharts




26/01/06                                       1
Language

    A set of symbols (alphabet) are needed to
    represent the instructions.
    Computer uses two symbols (0 and 1) to
    represent both instructions and data. This
    language is called machine language (low
    level language).
    Since it is difficult for human beings to use
    the machine language, high level languages
    are invented.
26/01/06                                            2
High Level Language (HLL)

    Similar to English which can be used easily
    by human beings.
    E.g.: C, Pascal, Java, Cobol, etc.
    HLL is independent of the Hard-Ware.
    A translator is needed to convert a program
    written in a HLL to the low level language.




26/01/06                                          3
Translators

    Compiler : Converts the entire program from
    high level to machine level.
        E.g. : C compilers like cc, gcc
    Interpreter : Converts an instruction into
    machine language and executes it, then goes
    to the next instruction.
        E.g. : Shell is a command interpreter.



26/01/06                                      4
Algorithm

    A finite sequence of unambiguous,
    executable steps which when followed
    achieves the specific objective.
    Always algorithm terminates.
    A program is a machine executable algorithm
    which may or may not terminate. (e.g. :
    Operating system is a program which does
    not terminate).


26/01/06                                      5
Flowchart: A representational scheme
for algorithms
    •      To find largest of three given numbers




26/01/06                                            6
   Algorithm: Largest of 3 Numbers
   1.      READ A, B, C
   2.      IF ( A > B ) THEN goto 8
   3.      IF ( B > C ) THEN goto 6
   4.      PRINT C
   5.      STOP
   6.      PRINT B
   7.      STOP
   8.      IF ( A > C ) THEN goto 10
   9.      Goto 4
   10.     PRINT A
   11.     STOP




26/01/06                               7
   Largest of a set of numbers.




26/01/06                          8
   Largest of a set of numbers.

           1.   READ number
           2.   largest = number
           3.   IF ( any more numbers) THEN goto 6
           4.   PRINT largest
           5.   STOP
           6.   READ number
           7.   IF ( number > largest ) then goto 2
           8.   Goto 3




26/01/06                                              9

				
DOCUMENT INFO
Shared By:
Categories:
Tags: linux, computer
Stats:
views:9
posted:4/15/2010
language:English
pages:9