You are on page 1of 84

Information and

Communication Technology
Class XI-XII

Chapter-5
Programming Language
Programming language
 Program: A set of sequentially arranged instructions
to solve a particular problem is called Program.

 Programming language provides interactions


between human and computer.
 Some special character/letter, words, rules, are to be
followed in a particular programming language.
 It needed to:
 Communicate with computer
 Send commands to computer
 Let computer work and solve problem for human
 Control the behavior of computer
Programming language
Defination (Contd.)
 A programming language is a formal
constructed language designed to
communicate instructions to a machine,
particularly a computer.
 Programming languages can be used to
create programs to control the behavior of a
machine or to express algorithms.
Examples some of programming language:

 C,ALGOL, Basic, Pascal, FORTRAN,


COBOL
 C++, Java, C#, Python, Visual Basic
A simple C Program for adding two numbers

#include<stdio.h>
main()
{
 int A,B,S; //variable declaration
 scanf( “ %d %d ” , &A, &B); Input

Processing  S=A+B;
 printf( “%d” , S); Output

}
Characteristics of a good program or
Features of a standard/ideal program

 A program should be as short a possible


 Faster execution
 Less time complexity
 All variable and constant should be declared
in the beginning of the program
 Algorithm, Pseudo code and Flowchart
should be given before the program
 Option should be kept for future
development
 Remarks/comments should be given
with important parts
 Unnecessary loop should be avoided
 Must have facility to get output
Generation of programming language
 1st Generation Programming Language

 2nd Generation Programming Language

 3rd Generation Programming Language

 4th Generation Programming Language

 5th Generation Programming Language


1st Generation Programming
Language
1st Generation Programming
Language
 Also called Machine language or low
level language
 Uses only 0 and 1.
 Communicate with computer directly
Advantages (Machine language)
 Communicate with computer directly
 No translator program needed
 Works faster
 Requires less memory spaces
 If we want to understand the internal
architecture of computer, we need to
learn machine language
Disadvantage (Machine language)

 Hard to write a program


 Writing a program is time consuming
 Chance to do mistake/error is very high
 Debugging(correction) is very hard
 Need to learn about internal structure of
computer
 Program written for one specific model
may not run in another model of computer
Stem:
 In ICT class Nafiza madam was discussing
about programming language. She told
that program were written only by using 0
and 1 long ago. In modern days C
programing is very popular.( After discussing
details about C programming she ask the
student to calculate the GCD of 6 and 12.)
 C) describe the language metioned in the
stem first.
2nd Generation programming Language

 Also called Assembly Language


 Use Symbolic Code for writing program
 Enable a programmer to use names
 Uses Mnemonic Code instead of numbers.
 Assembly language is a low-level
programming language/Also mid level
 Assembly language implements a symbolic
representation of the machine code needed
to program a given CPU architecture.
Some Assembly Language Command

 ADD= Addition
 SUB= Subtraction
 MUL = Multiply
 DIV= Division
 MOV= Move
 LDA = Load
 STP= STOP
Opcode Source Operand

ADD AX,Y
Destination Operand

It will calculate summation of AX


and Y and keep the result in AX
Example: write a assembly program to
find the result of A + (B * C )+ D
 MOV BX , B
 MOV CX , C
 MUL CX , BX

 MOV AX , A
 ADD AX , CX
 MOV DX, D

 ADD AX, DX
Example : ( A * B )+ (C * D)
 MOV AX , A
 MOV BX , B
 MUL AX , BX
 MOV CX , AX

 MOV AX , C
 MOV BX , D
 MUL AX , BX

 ADD AX , CX
Advantages of assembly language
 Almost direct communication with
computer
 Works faster (but slower than machine
language )
 Easier than machine language
 Writing program is fast
 Requires less memory spaces
Disadvantages of assembly language
 Hard to write a program (although easier
than machine language)
 Need to learn about internal structure of
computer
 Program written for one specific model
may not run in another model of
computer
 Requires more time to run (since needed
to translate in machine language)
3rd Generation Programming Language

 High level Language


 Very similar to human language
(English) that easy for human being
 Computer can’t recognize directly so
needed to be translated by translator
program

 Example:
 C/C++, JAVA, C# etc
Advantage of high level language
 Easy to write a program
 Less time for writing a program
 Chance to do mistake/error is low
 Debugging is easy
 No need to learn about internal
structure of computer
 Program written for one specific model
runs in another model of computer
Disadvantages of high level language

Can’t communicate with


computer directly.
Need translator program
Works slower
Requires more memory spaces
 On the date of 12/08/2016 the ICT teacher was discussing
in the class on the Program the solution to the general
problems to make the computer know the programming
language of a generation with the help of computer and
told that in the next class he would teach how to find out the
result of a number of digit in a series with the help of C
programming. Next day after writing the series 221 + 223
+ 225 + ------- + N on the black board.
 (c) Make the program of finding out the result of a series
mentioned in the Stimuli with the help of C language.
 (d) Which of the programs mentioned on the date in Stimuli
by the ICT teacher? Do you think is more useful? Illustrate
your answer.
Low level language VS High Level Langauge

Low level language High Level language

Uses only 0 and 1 Very similar to human


language (English) that
easy for human being

Communicate with Computer can’t recognize


computer directly directly
Not needed to be Needed to be translated
translated by translator program
Works faster Works slower
Requires less memory Requires more
spaces memory spaces
Dependent on internal Not dependent on
structure of computer internal structure of
computer
Hard to write a Easy to write a
program program
Chance to do Chance to do
mistake/error very high mistake/error Low

Debugging is very hard Easy to debug


Database
 The collection of data, usually referred to as
the Database, contains information relevant
to an enterprise.

Roll Name GPA

1 Shuvo 5.00
2 Riad 4.88
3 Abir 4.50
4 Soha 4.88
4GL
 Fourth Generation Languages are also
known as very high level languages.

Example:
SQL, Oracle, MS Access
HTML, DHTML, PHP,ASP
 Any language with English-like commands
that does not require traditional input-
process-output logic falls into this category.

 It’s a non-procedural programming language


that requires less coding
 allow programmers and users to specify
what the computer is supposed to do
without having to specify how to do it

 so much easier to use


The main domains and families of 4GLs are:

 Database queries (searching ) and


sorting data
 Database management
 data insert , delete and update
 Reportgenerators
 Data manipulation, analysis
 Mathematical calculation/optimization
 web development
Objectives of fourth generation languages

 Increasing the speed of developing


programs.
 Minimizing user effort to obtain information
from computer.
 Decreasing the skill level required of users
so that they can concentrate on the
application rather than the intricacies of
coding, and thus solve their own problems
without the aid of a professional programmer.
 Minimizing maintenance by reducing
errors and making programs that are
easy to change.

 Examples:
 SQL (Structured Query Languages)
 Visual Basic, Oracle
 Markup languages like HTML and XML
A fifth generation programming language

 A fifth generation programming


language (5GL) is a programming
language based on solving problems
using constraints given to the program,
rather than using an algorithm written by
a programmer.
AI & Neural Network
 Fifth-generation languages are used mainly
in artificial intelligence and neural networks
research. 
 Examples
 Prolog, 
 OPS5,
 LISP
 CLISP
 KL-ONE
 Mercury , Intellect
 Fifth-generation languages are
designed to make the computer solve a
given problem without the programmer.
 The programmer only needs to worry
about what problems need to be solved
and what conditions need to be met,
without worrying about how to
implement a routine or algorithm to
solve them.
Stem:
 On the date of 12/08/2016 the ICT teacher was
discussing in the class on the Program the solution to
the general problems to make the computer know the
programming language of a generation. With the help
of computer and told that in the next class he would
teach how to find out the result of a number of digit in a
series with the help of C programming.

 (d) Which of the programs mentioned on the date in


Stimuli by the ICT teacher? Do you think is more
useful? Illustrate your answer.
Translator Program

High Translator Low level/


Level Program/ Machine
Language Software Language
Translator Program

Source Translator Object


Program/ Program
code
Program
Translator program
A translator is a computer program
translate high level language into Low
level language
Translator Program

High Translator Low level/


Level Program/ Machine
Language Software Language
Why translator program needed?
 Human like to write program in high level
language
 Computer can understand only low level
language(0 and 1)
 So people writes program in high level
language ( C/C++, Java etc)
 translator program convert it into machine
language by using translator program
Types of Translator program

Translator

Compiler Interpreter Assembler


An imaginary example of compiler!

#include<stdio.h>
main() 0101010101001
{ 110001
Compiler 1010100101010
printf(“Hellow World”);
} 010101010
01011
An imaginary example of Interpreter !

START
1101
PRINT “Hello World”
Interpreter 111101010111
END
1110
Assembler

MOV AX , B 1010101010101
MOV BX , C 1010100101010
MUL AX , BX 000100101011
1010111010101
MOV BX , A Assembler 101111101110
ADD AX , BX 1010100101111
MOV BX, D 10101011111111
ADD AX, BX
Assembler

Assembly
Language Assembler Machine
Language
 Compiler:
 Translate high level language program into low level
machine language
 Take entire program at a time

 Interpreter:
 Translate high level language program into
intermediate code
 Take one line (or one statement) at a time
 Assembler:
 Translate assembly language program into low level
language
Interpreter

Compiler
Compiler Vs Interpreter

Compiler Interpreter
1. Translate high level 1. Translate high level
language program into low language program into
level machine language intermediate code
Compiler Vs Interpreter

Compiler Interpreter
1. Translate high level 1. Translate high level
language program into low language program into
level machine language intermediate code
2. Take entire program at a 2. Take one line (or one
time statement) at a time
Compiler Vs Interpreter

Compiler Interpreter
1. Translate high level 1. Translate high level
language program into low language program into
level machine language intermediate code
2. Take entire program at a 2. Take one line (or one
time statement) at a time
3.Works faster 3. Works slower
Compiler Vs Interpreter

Compiler Interpreter
1. Translate high level 1. Translate high level
language program into low language program into
level machine language intermediate code
2. Take entire program at a 2. Take one line (or one
time statement) at a time
3.Works faster 3. Works slower
4. All errors (bugs) are 4. Error message shown
shown together when any error is found
Compiler Vs Interpreter

Compiler Interpreter
1. Translate high level 1. Translate high level
language program into low language program into
level machine language intermediate code
2. Take entire program at a 2. Take one line (or one
time statement) at a time
3.Works faster 3. Works slower
4. All errors (bugs) are 4. Error message shown
shown together when any error is found
5. Debugging is harder 5. Debugging is easier
Compiler Vs Interpreter

Compiler Interpreter
6. Larger translator program 6. Smaller translator program
Compiler Vs Interpreter

Compiler Interpreter
6. Larger translator program 6. Smaller translator program
7. Requires more memory 7. Requires less memory
spaces spaces
Compiler Vs Interpreter

Compiler Interpreter
6. Larger translator program 6. Smaller translator program
7. Requires more memory 7. Requires less memory
spaces spaces
8. Translate into machine 8. Translate into intermediate
language or Object program. code. So the work is not fully
So the work is fully completed completed.
Compiler Vs Interpreter

Compiler Interpreter
6. Larger translator program 6. Smaller translator program
7. Requires more memory 7. Requires less memory
spaces spaces
8. Translate into machine 8. Translate into intermediate
language or Object program. code. So the work is not fully
So the work is fully completed completed.
9. Once a program is 9. Intermediated code is
translated not needed to needed to be translate again
translate again (if no change is for producing machine
made in source code) language.
Compiler Vs Interpreter

Compiler Interpreter
6. Larger translator program 6. Smaller translator program
7. Requires more memory 7. Requires less memory
spaces spaces
8. Translate into machine 8. Translate into intermediate
language or Object program. code. So the work is not fully
So the work is fully completed completed.
9. Once a program is 9. Intermediated code is
translated not needed to needed to be translate again
translate again (if no change is for producing machine
made in source code) language.
10. Used In C programming 10. Used In QBasic
programming
3 steps of Program organization
 INPUT A, B INPUT

 Sum= A+B PROCESSING

 PRINT Sum OUTPUT


Organization of a program

Input Process Output


 Input:
 the data/information and instructions that are
given as input into computer

 Process:
 process the data according to instructions

 Output:
 after processing the result is to be shown
 INPUT A, B INPUT

 S = A+B PROCESSING

 PRINT S OUTPUT
A simple C Program for adding two numbers

#include<stdio.h>
main()
{
 int A,B,S;
 scanf( “ %d %d ” , &A, &B); Input

Processing  S=A+B;
 printf( “%d” , S); Output

}
Steps of developing a program
1.Problem Specification

2. Problem Analysis

3. Program Design

4. Program Development

5.Program Implementation

6. Documentation & Maintenance


1.Problem Specification:
 Discuss with the concern persons
 Identify the problems properly
 Determine the inputs and outputs
2. Problem Analysis
 Break down the problem into small sub- problems
 Build a mathematical model
 Estimate the time needed for the solution
3. Program Design

 Determine the relations among the


sub-problems
 find solutions through analysis tools
like:
 Algorithm,
 Pseudo code
 Flowchart etc
3. Program Design(Contd.)

Input design
Output design
Find the relation between Input
& Output
4. Program Development

 Program written according to algorithm,


Flowchart or Pseudo code. It is called
Coding.

 C/C++, Java, C#, Visual Basic or any


programming language can be used in this
purposes
4. Program Development(contd.)
 Test the program, finding and correcting errors
(debugging) until it is error free and contains
enough safeguards to ensure the desired
results
5. Implementation
 Buy necessary
Hardware
 Software installation
 Training of the user
6. Documentation and Maintenance

 All of the flowcharts, algorithms, lines of code,


remarks/comments and the user manuals are
part of this documentation.

 Internal documentation is used by other


programmers to help them know why you did
something a certain way or tell them how you
wrote a program.
6. Documentation and Maintenance…..

 Provide support to users


 correct any unanticipated
errors that emerge
 identify user-requested
modifications
(enhancements).
 Once errors or
enhancements are
identified, the program
development life cycle
begins again at Step 1.
Debugging
 Bug= Small insect
 Debugging is a process of finding and correcting the
bugs (errors) in a computer program. 

 Techniques for debugging:

 Read the program from top to bottom carefully


 Simplify the program by reducing statements
 ( or inactive some statements)

 Use debugging tools


 Step 1: Read two Numbers
 Step 2: Add the Two numbers and multiply
by first number
 Step 3: Print the Result

 C) Draw the Flowchart


 D) how the steps are related with steps
of a program development?
Types of errors

 Syntax errors
 Semantic/Execution/Runtime error
 Logical errors
 Linker error
Types of errors
 Syntax errors: errors due to the fact that the syntax
of the language is not respected.
 Sum=A+B
 if(a>b);
 int 2b;
 Semantic/Execution/Runtime error: errors due to
an improper use of program statements. Like:
 Divided by zero
 The loop is infinite
 Square root of negative number
 Array overflow
 Logical errors: errors due to the fact that the
specification is not respected.
 Use of > instead of <
 Use of R= A * B, instead of R= A/B;

 Linker error: wrong function call


 Header file not included
 You have used “scanf()” but not wrote
#include <stdio.h>

You might also like