Download presentation
Presentation is loading. Please wait.
Published byWakeel Saim Modified over 5 years ago
1
PROGRAMMING FUNDAMENTALS Lecture # 03
2
Programming Language A Programming language used to write computer programs. Its mean of communication between user and the computer. There are two categories to Computer Programming Language 1.High Level Language 2.Low Level Language COMPUTER LANGUAGES
3
Low Level Language A low level programming language is a programming language that provides little or no abstraction from a computer’s instruction set architecture. It consists of numeric codes i-e 0 &1. These codes are easily understandable to computer but difficult to human. A low level language is used in two generations of computer. 1.First generation 2.Second Generation LOW LEVEL LANGUAGE
4
Represent the very early, primitive computer language that consisted entirely of 1’s and 0’s – the actual language that the computer understands (machine language). FIRST GENERATION LANGUAGE OR 1GL
5
Represent a step up from the first generation languages. Allow for the use of symbolic names instead of just numbers. Second generation languages are known as assembly languages. Code written in an assembly language is converted into machine language (1GL). SECOND GENERATION LANGUAGE OR 2GL
6
A Type of language that is close to human languages is called high level language. High level languages are easy to understand. Instructions o these languages are written in English-like words such as input and print etc. Examples: Cobol Java C/C++ Visual Basic HIGH LEVEL LANGUAGE OR 3GL
7
Source Code A program written in a high level language is called source code / source program. The source code cannot be executed by computer directly. It is converted into object code and then executed. Object Code A program in machine language is called object code / object program / machine code. Computer understands object code directly. SOURCE AND OBJECT CODE
8
Language Translators Convert Programming source code into language that the computer processor understands. Programming source code has various structures and commands, but the computer processors understand only machine language. Language translators are of three types:- 1.Compiler 2.Interpreter 3.Assembler LANGUAGE TRANSLATORS
9
Scans the entire program and translates it as a whole into machine code. It takes large amount of time to analyze the source code but the overall execution time is comparatively faster. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Programming language like C, C++ use compilers. COMPILER
10
Translates program one statement at a time. It takes less amount of time to analyze the source code but the overall execution time is slower. Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy. Programming language like Python, Ruby use interpreters. INTERPRETER
11
An assembler is a program that converts assembly language into machine code. It takes the basic commands and operations from assembly code and converts them into binary code that can be recognized by a specific type of processor. ASSEMBLER
12
SYNTAX ERROR Errors that occur when you violate the rules of writing C/C++ syntax are known as syntax errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by compiler and thus are known as compile-time errors
13
SYNTAX ERROR Example #include void main() { printf(“Hello Pakistan”) }
14
SYNTAX ERROR Example #include void main() { printf(“Hello Pakistan”)// semi-colon missed }
15
On compilation and execution of a program, desired output is not obtained when certain input values are given. These types of errors which provide incorrect output but appears to be error free are called logical errors. These are one of the most common errors done by beginners of programming. LOGICAL ERROR
16
Example #include void main() { int i; for(i=0;i<3;i++); printf(“Loop”); getch(); } LOGICAL ERROR
17
Example #include void main() { int i; for(i=0;i<3;i++); // logical error : a semicolon after loop printf(“Loop”); getch(); } LOGICAL ERROR
18
Errors which occur during program execution(run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error. These types of error are hard to find as the compiler doesn’t point to the line at which the error occurs. RUN TIME ERROR
19
Example #include void main() { int i = 10; int ans; ans = i / 0; printf(“ Result = %d”, ans); getch(); } RUN TIME ERROR
20
Example #include void main() { int i = 10; int ans; ans = i / 0; printf(“ Result = %d”, ans); getch(); } RUN TIME ERROR Wrong logic Number divided by zero So this program abnormally terminates.
21
What are linker and loader??
22
Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.