Upload
krishna-yadav
View
218
Download
4
Embed Size (px)
Citation preview
UNIT 2
A program is a set of logically related instructions that are arranged in a sequence that guide the computer to solve a particular problem. The process of writing such programs for an analyzed problem is called programming or coding, if a system is not correctly programmed it will produce incorrect result
`
A language is a system of communication. In order to communicate with each other, human beings need languages like, English ,French, Hindi etc. in the same way for communication with computer we need computer languages ,the computer language is also known as programming languages .” A programming language is a set of written symbols, characters and usage rules that instruct the computer hardware to perform a specific task,
use of these symbols is governed by set of rules called syntax
Fundamental difference between a natural language and computer language is that in case of natural language people can use incorrect vocabulary ,grammar and style and make themselves understand
However in computer languages correct syntax is must ,i.e. even a single ,small syntax error make the program error prone.
so computer languages are very much sensitive to their syntaxes ,incorrect words punctuation marks and spelling etc, which make program syntactically incorrect
Computer languages are classified in following four categories
• Declarative languages• Machine language• Assembly language• High level language
• Declarative language -: Declarative language -: these are just like English in their expressive power and functionality ,that’s why these are kept at the highest level ,basically command languages dominated by statement which express what to do rather than how to do
• Machine language -: Machine language -: directly understood by computer without any translation, in the form of binary strings 1 and 0
• Entire circuitry of a computer is designed in such a way that it understands the machine language instructions and converts them into electrical signals required to run the computer
• Instructions written in any machine language has two parts
operation code operand location or addressOperation code-: indicate the name of command or
operation to be performed by the computer ,in other words it direct the computer that what function has to be performed
• Operand address/location -: it tell the computer where to find or store the data or instruction that are to be operated ,in this manner each instruction tell the control unit of the computer ,what to do? And the address of the data to be operated upon
• Machine level languages are low level language, difficult to write, learn, understand
Disadvantage-: Disadvantage-: • machine dependent• Difficult to write program• Error prone• Difficult to modify
Assembly languageAssembly language
• Low level language ,knowledge of hardware specification is must
• Use of mnemonics in place of machine code, this made the programming easy and efficient ,by using mnemonics the programmer need not to remember operation codes and storage locations
Mnemonics-: Mnemonics-: lLDA – LoadingMUL- multiplyingSUB- subtracting
Example-: CLA XADD YSTA ZTYP ZHLT
Computer cannot execute an assembly language program directly because computer can understand only binary codes ,translator translates assembly language program into machine code is known as assembler
• Program that is written in language other than machine language is called source program, the translated program into machine code is called object code
Execution process-: 1 when computer is switched on ,the loader program is
automatically loaded in the main memory2) Now loader stores the assembler in the main memory3) Assembler reads each instruction of an assembly
language program one by one and converts it into machine code and stores in main memory
• After full conversion into machine code, each instruction of machine code is executed
Advantages Advantages • Easier to memorize • Easy to write input data• Easy to detect and correct error• Easy print out• Good library facility
• DisadDisadvantagesTime consumingMachine dependentKnowledge of hard ware required
High level languageHigh level language
• Problem oriented and machine independent, instructions or commands are generally written using English words and mathematical symbols, it does not use mnemonic code
Features Features Problem orientedMachine independentSymbolic languageSimple in nature
• Easy to write and understand the program• Arithmetic rules are well defined
Types of HLLTypes of HLLCommercial languages - COBOLScientific languages -: APL, FORTAN 77Special purpose languages -: GPSSCommand languagesMultipurpose languages
advantagesadvantages
• Readability• Machine independent• Fewer error and easy debugging• Lower program preparation cost• Better documentation• Easier to maintain• Easy to understand
disadvantagesdisadvantages
• Speed• Memory