• No results found

Introduction to Programming Languages

N/A
N/A
Protected

Academic year: 2020

Share "Introduction to Programming Languages"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 1111

Introduction to Programming Languages

Basic Definitions in Programming

Data

Data is raw, unorganized facts that need to be processed. Data can be something simple and seemingly random and useless until it is organized.

For example, Each student's test score is one piece of data.

Information

When data is processed, organized, structured or presented in a given context so as to make it useful, it is called information.

The average score of a class or of the entire school is information that can be derived from the given data.

Program

A Program is a set of instructions written by following the syntax of programming languages to perform a well defined task.

Execution of a Program or Running a Program

The process of Loading or Storing instructions of a program in the computers main memory is called as execution of program. The instructions in the main memory are ready to be executed by the micro processor.

Compiler

(2)

C CC

C----Programming LanguageProgramming LanguageProgramming LanguageProgramming Language

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 2222 Interpreter

Interpreters are not much different than compilers. They also convert the high level language into machine readable binary equivalents. But it converts one statement at a time. Each time when an interpreter gets a high level language code to be executed, it converts the code into an intermediate code before converting it into the machine code.

Difference between Compiler and Interpreter

The main differences between compiler and interpreter are listed below:

The interpreter takes one statement then translates it and executes it and then takes another statement. While the compiler translates the entire program in one go and then executes it.

Compiler generates the error report after the translation of the entire page while an interpreter will stop the translation after it gets the first error.

Compiler takes a larger amount of time in analyzing and processing the high level language code comparatively interpreter takes lesser time in the same process.

Besides the processing and analyzing time the overall execution time of a code is faster for compiler relative to the interpreter.

Programming Language:

A programming language is a set of commands, instructions, and other syntax use to create a software program. Languages that programmers use to write code are called "high-level languages." This code can be compiled into a "low-level language," which is recognized directly by the computer hardware.

We have three types of Computer Languages.

(3)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 3333 Assembly Level Programming Language

The language that contains all the Mnemonic Symbols is known as ALP.

Mnemonics: Add, Sub, Mul etc..

Machine Level Programming Language

A language that can be understood by the machine in the form of 0’s and 1’s is known as MLP.

High Level Programming Language

A Language which contains just like English like words is known as HLP.

Example: C, CPP, Java etc.

Classification of High Level Programming Languages

According to the type of data being accessed by the function in the program they are divided into 4 types.

1. Monolithic Programming Language.

2. Procedure Oriented Programming Language. 3. Structure Oriented Programming Language. 4. Object Oriented Programming Language.

Monolithic Programming Language

In this language the program statements are appeared in a fault order and the flow of control is achieved by jumping control statements(goto). It does not consists any sub routines and it is very difficult to write programs using this language.

(4)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Procedure Oriented Programming Language

In this language the problem is divided into smaller pieces known as procedures. Every complex program is divided into smaller individual procedures. Every procedure uses Common data of the program.

Example: COBOL (Common Business

Structure Oriented Programming Language

Now a day the most popular programming language is language. It has enhanced features than the previous languages.

These languages are emphasis on algorithm rather than the data.

Large projects can be divided into smaller elements known as modules.

Every module is independent of one another.

The concept of control structures is introduced and hence we easily estimat the program.

The concept of data types is also introduced. Every function having its own data and can also access global data. It follows top

Example: C-Language

C CC

C----Programming LanguageProgramming LanguageProgramming LanguageProgramming Language

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E,

Department of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupurVishnupur Procedure Oriented Programming Language

In this language the problem is divided into smaller pieces known as procedures. Every complex program is divided into smaller individual procedures. Every procedure uses Common

(Common Business-Oriented Language)

Structure Oriented Programming Language

Now a day the most popular programming language is structure oriented programming language. It has enhanced features than the previous languages.

These languages are emphasis on algorithm rather than the data. Large projects can be divided into smaller elements known as modules. Every module is independent of one another.

The concept of control structures is introduced and hence we easily estimat

The concept of data types is also introduced. Every function having its own data and can also access global data. It follows top-down approach.

Programming Language Programming LanguageProgramming Language Programming Language

Vishnupur Vishnupur Vishnupur

Vishnupur Page Page Page Page 4444

In this language the problem is divided into smaller pieces known as procedures. Every complex program is divided into smaller individual procedures. Every procedure uses Common

structure oriented programming

Large projects can be divided into smaller elements known as modules.

The concept of control structures is introduced and hence we easily estimate the flow of

(5)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 5555 Object Oriented Programming Language

The most powerful and efficient language is Object Oriented Programming Language. It has the following features.

1. Classes and objects are introduces in OOP. 2. We can provide the security to our data. 3. It can emphasis on data rather than algorithm.

4. Every object can send messages to other in terms of functions. 5. It follows Bottom-up approach.

6. Using OOP we can develop internet programs.

Example: Java and C++.

Explain about the Programming Methodologies

Programming methodology deals with the analysis, design and implementation of programs. There are two types of programming methodologies.

Top-Down programming approach

Bottom-Up programming approach.

Top-Down Programming Approach

The large program is divided into many small module or subprogram or function or procedure from top to bottom.

At first supervisor program is identified to control other sub modules. Main modules are divided into sub modules, sub-modules into sub- sub- modules. The decomposition of modules is continuing whenever desired module level is not obtained.

(6)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E,

Example:

The main program is divided into sub

subprogram A1, A2 and A3.The B is into B1, and B2. Just like these divided into three subprogram

sub program A, B and C.

Bottom up Approach

• In this approach designing is started from bottom and advanced stepwise to top. So, this approach is called Bottom up

• At first bottom layer modules are designed and tested, second layer modules are designed and combined with bottom layer and combined modules are tested. In this way, designing and testing progressed from bottom to top.

• In software designing, only pure top down or Bottom up approach is not used. The hybrid type of approach is recommended by many designers in which top down and bottom up, both approaches are utilized.

C CC

C----Programming LanguageProgramming LanguageProgramming LanguageProgramming Language

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E,

Department of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupurVishnupur

Top down Approach

The main program is divided into sub-program A, B, and C. The A is divided into subprogram A1, A2 and A3.The B is into B1, and B2. Just like these subprograms, C is also divided into three subprograms C1, C2 and C3. The solution of Main program

In this approach designing is started from bottom and advanced stepwise to top. So, this Bottom up approach.

At first bottom layer modules are designed and tested, second layer modules are designed and combined with bottom layer and combined modules are tested. In this way, designing and testing progressed from bottom to top.

ware designing, only pure top down or Bottom up approach is not used. The hybrid type of approach is recommended by many designers in which top down and bottom up, both approaches are utilized.

Programming Language Programming LanguageProgramming Language Programming Language

Vishnupur Vishnupur Vishnupur

Vishnupur Page Page Page Page 6666

program A, B, and C. The A is divided into subprograms, C is also

program is obtained from

In this approach designing is started from bottom and advanced stepwise to top. So, this

At first bottom layer modules are designed and tested, second layer modules are designed and combined with bottom layer and combined modules are tested. In this way, designing

(7)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 7777

Algorithms and Flow Charts

Introduction to Algorithm

Every programming language has its own construction or instructions to understand. The most popular technique used to get a plan for the solution of a given problem after analyzing in multiple dimensions is an algorithm.

An algorithm is a step by step representation of a given problem in English like statements. Algorithm is a problem solving activity.

Standard definition of an algorithm

An algorithm consist of set of explicit unambiguous, finite steps, which takes input and produce output definitely in a finite time.

Every algorithm must be made up of following steps.

Step1: Start

Step2: Body of the algorithm.

Step3: Stop.

Factors of an Algorithm

Every algorithm is influences with the following five factors.

1. Input

2. Output

3. Definiteness.

4. Finiteness.

5. Effectiveness.

Input: Input is nothing but the data given to the problem.

Output: Output is nothing but the problem generated result.

Definiteness: The algorithm should definitely find the solution for the given problem.

Finiteness: The number of steps in algorithm is finite.

Effectiveness: The efficient one that find the solution for a given problem than remaining

(8)

C CC

C----Programming LanguageProgramming LanguageProgramming LanguageProgramming Language

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 8888 Examples for an Algorithm:

1. Write an algorithm to print “Hello World” on the console.

Step1: Start

Step2: Print “Hello World” by using printf statement.

Step3: Stop.

2. Write an algorithm to find the addition of two numbers.

Step1: Start

Step2: Input two values into the variables ‘a’ and ‘b’ from the keyboard.

Step3: Find the addition of ‘a’ and ‘b’ i.e., a+b and assign the resultant value to the variable ‘c’

Step4: Print the addition value ‘c’.

Step5: Stop

3. Write an algorithm to swap two numbers by using the third variable.

Step1: Start

Step2: Read ‘a’ and ‘b’ values from the keyboard.

Step3: Before swapping print the values of ‘a’ and ‘b’.(For example a=10 and b=20).

Step4: Assign the value of ‘a’ to the variable ‘temp’ i.e., temp=a.

Step5: Assign the value of ‘b’ to ‘a’ i.e., a=b.

Step6: Assign the value of ‘temp’ to ‘b’ i.e., b=temp.

Step7: After swapping print the values of ‘a’ and ’b’.(In this a=20 and b=10).

(9)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 9999

Flowchart

The pictorial presentation of program is called Flowchart. It is a tool and technique to find out solution of programming problems through some special symbols. It is a way to represent program using geometrical patterns.

Flow Chart

• The graphical or visual representation of algorithm is called as flow chart.

• The flow charts are easier to understand the flow of the solution.

• Flow charts are drawn with the standard symbols accepted worldwide.

(10)

C CC

C----Programming LanguageProgramming LanguageProgramming LanguageProgramming Language

(11)

Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, Department of Computer Science, B.V.R.I.C.E, VishnupurDepartment of Computer Science, B.V.R.I.C.E, VishnupurVishnupurVishnupur Page Page Page Page 11111111 Important Questions

1. Define a program and explain the types of programming languages.

2. Explain about the Programming Methodologies (Top-Down and Bottom-Up Approaches).

3. Define Compiler and Interpreter and explain the differences between them. 4. Define an Algorithm and explain the factors of an algorithm.

5. Write any three algorithms.

References

Related documents

Spatial diversity gain of MIMO single frequency network in passive coherent location.. Nazari

Mean household income of low-impact forest products, bamboo, climber, coffee and honey (FP)(US$), and high-impact FP, timber and fuelwood (US$), established through market price

Kwame Nkrumah’s Independence Speech as “the greatest speech ever written and delivered in Ghanaian geo-politics and rhetorical history.” The objective of the study is

Considering the different results of the previous stud- ies, the aim of the present study is to compare the mar- ital satisfaction, marital intimacy, sexual satisfaction and

Due to the fact that human liver tissue of multiple injured patients is hardly available for re- search, we investigated the regulation of murine beta defensin 4 (MBD-4) [19], which

Using the profile, the kyphotic and lordotic angle, the surface rotation, the lateral deviation, pelvic tilt and pelvic torsion, statistical differences at T1 and T2 between the

O & M Capital costs Total installation costs Interest rate Availability Power curve Energy production Total costs Cost of energy per MWh Lifetime of project Number of load