190 likes | 444 Views
Computer programming. Computer programming. the objective of the module to gain the necessary skills to develop a computer program using one of the high level language. Introduction. What is a computer?
E N D
Computer programming • the objective of the module to gain the necessary skills to develop a computer program using one of the high level language.
Introduction • What is a computer? a computer is a device that accepts information (in the form of digitalized data) and manipulates it for some result based on a program or sequence of instructions on how the data is to be processed. • What is a computer program? Sets of instructions that control computer’s processing of data, which are carried out to perform an intended task.
what are computers used for? • Data processing: for commercial and financial purposes ( such as billing, shipping and receiving) • Scientific processing: to support science ( raw data analysis, modelling natural phenomenon) • Multimedia: (composing music, performing music, recording music, editing film and video, special effects, animation, illustration, laying out print materials, etc.)
Parts of a computer • Computers’ parts can be divided into five elements: • Arithmetic and logic unit(ALU). • Central processing unit(CPU). • Main storage. • Input unit. • Output unit.
Arithmetic and logic unit(ALU). • performs integer arithmetic and logic operations. • other specialized operations. • Central processing unit(CPU). • “Administrative” section • Supervises and coordinates other sections of computer. • contains an arithmetic/logic unit (ALU), control unit and internal buses. • Main storage. • called memory or internal memory. • RAM (Random Access Memory)( static or dynamic) • ROM (Read Only Memory) also is random.
Input unit. • “Receiving” section • Obtains information from input devices such as Keyboard, mouse, microphone, scanner, networks. • Output Unit • Shipping” section • Takes information processed by computer • Places information on output devices • Screen, printer, networks, …
Software • What is the software? Programs that run on computer.
Classification of the software • operating system • control the flow of data through all the computers’ units. • Mange all the computer units • Monitoring the executions of the programs • Controlling storing data on the storage units • ……….
Classification of the software • Utility programs • serve the final users • Word, excel ……
Classification of the software • Programming languages • Have been used to create computer programs • Example: Java, C#, C and C++.
Types of programming languages • Machine language • Only language computer directly understands • “Natural language” of computer • Defined by hardware design • Machine-dependent • Generally consist of strings of numbers • Ultimately 0s and 1s • Instruct computers to perform elementary operations • One at a time • Hard to understandfor humans • Example: • +1300042774+1400593419+1200274027
Types of programming languages • Assembly language • English-like abbreviations representing elementary computer operations • Clearer to humans • Incomprehensible to computers • Translator programs (assemblers) • Convert to machine language • Example: • LOAD BASEPAYADD OVERPAYSTORE GROSSPAY
Types of programming languages • High-level languages • Similar to everyday English, use common mathematical notations • Single statements accomplish substantial tasks • Assembly language requires many instructions to accomplish simple tasks • Translator programs (compilers) • Convert to machine language • Interpreter programs • Directly execute high-level language programs • Example: • grossPay = basePay + overTimePay
Examples following sentence is written using Pascal as a high level programming language “ if (x=y)and (z=w)then writeln(‘the answer is Yes’);” Notes: • Easy to understand for human. • Can not be understood by CPU. • Has to be translated to low level language.
Con. Examples following sentence belongs to assembly language as a low level programming language “ ADD XYZ” which can be translated to: • add the number which is existing in the memory at the location x to the number at the location y then store the result at the location z.
Con. Example Notes: • Difficult to the programmer. • Still can not be understood by the CPU. • Needs to be translated to low level language.
Con. Example • the above sentence needs to be translated to a sequence of zeros and ones (01) to be executed. • if ADD is translated to 0110 • x 1001 • y 1010 • z 1011 • The sentence is going to be like 0110100110101011 and is ready to be executed.
What are Interpreters, compilers and assemblers? • Interpreter: it converts each high level instruction into a series of machine instructions and then immediately run (or execute) those instructions. • Compilers: convert a finished program (or section of a program) into object code. This is often done in steps. • Assemblers: program which convert the symbolic instructions ( which is written in an assembly language) into object or machine code.