Lecture 1 - Introduction to Programming



Program is a sequence of instructions which is given to the computer to perform some specific task.
There are two categories of languages

  1. High Level Language 
  2. Low Level Language

High level languages are close to human languages. These languages have English like words in them. For example

if, else, switch, for, while, do-while, printf, scanf, main, long, double etc

For example: C, C++, Java, Basic, Visual Basic, Visual C++, Visual C#, PHP, FORTRAN, and COBOL etc.

Features of High level languages
  • Easy to Learn 
  • Easy to Modify 
  • Easy to Debug 
  • Platform Independent 
  • Shorter programs as compared to Low level languages 
  • Less production cost
Low level languages are NOT close to human language these languages have either symbols or binary numbers.

  • Machine Dependent
  • Larger programs 
  • High production cost 
  • Difficult to Debug

 

Comparison of different languages


C Language
Assembly
Machine (Suppose)
Electric Pulse
a = 5;
mov ax, 5
01 [01] 101
It is called Source Code
Mnemonic Code
It is called Object Code
Bits
Table 1 – Code Comparison Different Languages

Source code is the program written in any high level language whereas the code written in machine language is called object code.


Source Code
Object Code
Source code is written in high level language
Object code is the machine code equivalent of Source Code
Needs to be compiled
Does not need compilation
Easier to type because it contains English like words
Difficult to create because it contains binary code
NOT Machine dependent
Machine dependent
Table 2 – Comparison of Source and Object Code
When we need to execute a program, that program needs to be in object code. For the conversion from Source code to Object Code we need to have software called a Language Translator.
There are two types of language translators
  • Compilers 
  • Interpreters
Compilers
Interpreters
Converts the complete program to machine code as a whole
Converts the program to machine code line-by-line
Fast as compared to Interpreters
More time consuming as each line is executed before the conversion of the next line
Errors are easily located as the program is converted as a whole
Errors cannot be easily located as each line is executed before the next, and if there’s an error it will not execute
Table 3 – Comparison of Compiler and Interpreter

You need to have an editor, compiler, linker and loader in order to type, compile, link and load and Execute C program. For your convenience we’ve an Integrated Development Environment (IDE) which provides an
·          
  • Editor – For typing your source Code 
  • Compiler – To convert your source program to object program 
  • Linker – To Link your source, header and data files 
  •  Loader – To Load your program in Memory

Comments

Popular posts from this blog

Lecture 17 – Functions (continued)

Lecture 6 – Operators in C (continued)

Lecture 10 – Decisions (if-else-if)