Please enable JavaScript.
Coggle requires JavaScript to display documents.
CHAPTER 1: INTRODUCTORY TO PROGRAMMING - Coggle Diagram
CHAPTER 1:
INTRODUCTORY TO PROGRAMMING
1.1 THE PROGRAMMING LANGUAGE
C language
Example
TWO(2) lines of code illustrate
printf(“ Hello world, welcome to C Programming”);
scanf(“%d”, &letter);
It uses a simple everyday-like- English abbreviation code for easy understanding by programmer.
a special language decided to instruct a
computer to do certain task.
supports functions that enables easy maintainability of code, by breaking large file into smaller modules.
a structured programming language
a powerful language
1.1.2 Explain the background of C programming
first developed in 1972 by Dennis Ritchie at AT & T Bell Labs.
is high level programming language
the most popular general purpose programming language.
is written as a series of functions that call each other for processing
The function is very flexible, allowing programmers to choose from the standard library that comes with the compiler to use third party functions from other C suppliers or to develop their own.
a high level language with features that support low level programming.
1.1.3 The sample of C program
1.1.4 The compiler and execute programs
A programmer uses a text editor to create or modify files
containing C code.
Code is also known as source code.
A file containing source code is called a source file.
After a C source file has been created, the programmer must invoke the C compiler before the program can be executed (run).
Compiler
A compiler is special program that processes statements written in a particular programming language and turns them into machine language or “code” that a computer’s processor uses.
Used to check the Programs for Errors
Compiler creates a object file if there is no error in the Source Code
1.2 DEFINITION AND TYPES OF PROGRAMMING
Programmer:
Programmer is a person who writes the program.
Programming:
Programming is a process of designing/ creating a program.
Program:
A set of step-by-step instructions that directs a computer to perform a specific task and to produce the required results.
1.2.2 The various types of programming languages.
Low-level languages.
Machine language
Language that computers can understand.
Instructions in this language are in the form of 1s and 0s.
Examples
101000100011001101 - Subtracting two numbers.
101000010011001101 - Adding two numbers.
Advantages of Machine Language
It makes fast and efficient use of the computer.
It requires no translator to translate the code i.e.Directly understood by the computer The computer processes the instructions in machine language very quickly.
Disadvantages of Machine Language:
All memory addresses have to be remembered.
It is hard to amend or find errors in a program written
Programmers must have knowledge of the machine hardware and its configuration.
Programmer needs to remember a number of binary codes to write machine language
programs.
These languages are machine dependent i.e. a particular
Machine language can be used on only one type of computer
All operation codes have to be remembered
Machine language programs are very difficult to debug.
Assembly language
Examples
ADD R1 R2 – Adds two numbers stored in registers R1 and R2.
SUB R1 R2 – Is the instruction in assembly language to subtract two numbers stored in the registers R1 and R2.
Advantages:
It is easy for programmers to remember the alphanumeric codes than the binary codes.
Debugging is very easy when compared to machine language.
It is easier to understand and use as compared to machine language.
It is easy to locate and correct errors.
It is modified easily
Uses symbolic instructions (mnemonics) to represent the instructions in the programs.
Disadvantages:
The major disadvantage is that, it is machine dependent.
Like machine language it is also machine dependent.
Since it is machine dependent therefore programmer Should have the knowledge of the hardware also.
High-level languages
Types of high level :
C
C++
Java
Visual Basic
Fortran
MySQL
Examples
a+b – Adds the variable a and b.
a-b – Substrates the variable b from a
Languages that use English words and mathematical symbols for writing programs.
Advantages:
The program is easy to port around on different computer platforms
It is not necessary for the programmer to have knowledge about computer hardware.
It is very easy to learn and write programs in high-level languages.
Language that enables development od a program in much simpler programming.
Generally easy for other human to understand
This language is also open to mostly any computer platform
The program is easy to maintain
The program is easy to read
They require less time to write.
Similar to English with vocabulary of words and symbols
User-friendly
level languages is to enable people to write programs easily and in their own native language environment (English).
High level computer languages give formats close to English language and the purpose of developing high
Disadvantages of High Level Language
The object code generated by a translator might be inefficient Compared to an equivalent assembly language program
Types of computer languages
A high-level language has to be translated into the machine language by a translator and thus a price in computer time is paid.
As we human beings communicate with each others in different language such as Urdu, French, Punjabi and Arabic etc. Similarly to communicate with the computers we have to use specific languages and for this.
Types of high-level language
C , C++, Java, Visual Basic, Fortran, MySQL, OOP, Pascal
1.3 UNDERSTAND THE TYPES OF PROGRAMMING AND STRUCTURE PROGRAMMING METHODOLOGY.
1.3.1 Types of programming
structured programming
The structured program is viewed as a series of task to be done, such as reading data, processing data and generating report or output.
The main program fragmented into smaller functions which are then
arranged in a hierarchical structure
Programming methodology in which the instructions are written in a
sequence.
The main characteristics of structured program:
It uses top-down approach
Use variables as identifiers
Unlimited data types, Most of the functions share global data.
The whole program is broken down large program into smaller functions/section are known as modules.
The functions pass the data around the system openly.
The functions transform the data from one form to another.
Can handle up to moderately complex programs
modular programming
A module is an independent segment of the program that performs a specific task.
When compared to structured programming, writing and
debugging modular programs are easy.
Programming methodology in which the complex program is broken into number of simple modules.
BENEFITS OF USING MODULAR PROGRAMMING.
Modular programming allows many programmers to collaborate on the same
application.
The code is stored across multiple files.
Programs can be designed more easily because a small team deals with only a small part of the entire code.
Code is short, simple and easy to understand
A single procedure can be developed to reused, eliminating the need to retype the code many time.
Errors can easily be identified, as they are localized to a subroutine or function.
Less code has to be written
The same code can be used in many applications.
The same code can be used in many applications.
object-oriented programming
Programming methodology in which the data and the code are treated as a single unit.
It does not allow data to move freely through the system. Instead, it binds the data to the functions that are needed to manipulate them.
This is to protect the data from accidental modifications by external functions to an object.
In Object-oriented Programming (OOP), problems are decomposed into a number of entities called objects. All the data are to build function around these objects.
The main characteristics of OOP
Combines data with functions to create objects which has relationship with one another. Emphasis is on data rather than functions.
Can handle very complex programs.
Unlimited data types by using class.
An object’s data is hidden from external functions.
Use objects as identifiers ,a program consists of a set of objects
Functions that operate on objects are tied to each data
Uses bottom-up approach
The objects communicate with one another through functions.
New data and functions can be added easily whenever necessary.