Notes1- Unit I -BCA 1-Semester-I-Basic concepts of Programming languages
Notes1- Unit I -BCA 1-Semester-I-Basic concepts of Programming languages
examinations separately.
2
Course Content for BCA, Semesters I
Corse Code: BCA-51T-101 Course Title: Programming in C
Course Credit : 04 Hours/Week: 04
3
Scheme of Examination
4
BCA-Semester-I-Course Code:51T-101: Programming in C
Syllabus:
UNIT- I
Basic concepts of Programming languages, Programming
Domains, Language Evaluation criteria and language
categories, Evolution of major programming languages.
Describing syntax and and semantics formal methods of
describing syntax, Pseudo code, Design of Algorithm &
Flowchart
UNIT- II
Fundamentals of C: History and importance of C, sample
programming, basic structure and execution of C programs,
constants, variables, and data types and various type of
declarations, different type operators and expressions,
evaluation of expressions, operator precedence and
associability. Managing input and output operations, decision
5
making and branching decision making.
Principles of Programming (Through ‘C’)
Iteration: while, do…while, for loop, nested loops, break &
continue, goto statements.
UNIT- III
Arrays and Strings: One-dimensional arrays and their
declaration and initialization, two-dimensional arrays and their
initializations, character arrays (One and Two dimensional),
reading and writing strings, string - handling functions.
6
Principles of Programming Language (Through ‘C’)
UNIT-IV
Understanding Pointers: Accessing the address of a variable,
declaration and initialization of pointer variables, accessing a
variable through its pointer, pointers and arrays, pointers and
function arguments, functions returning pointers.
7
Principles of Programming Language (Through ‘C’)
Recommended Books:
1.Balagurusamy E; Programming in ANSI C;Fifth Edn; Mc Graw Hill,2011.
2.Kanetkar Y.; LET US C; X Edition, BPB,2010.
3.Deitel HM & Deitel JP; C How to program; 5th Edn; Pearson Pub
4.Gottfried B; Programming with C: Schaum Qutlines; Mc Graw Hill Edition.
8
BCA-Semester-I-Course Code:51T-
101: Programming in C
9
Basic concepts of Programming languages
UNIT – I
10
Basic concepts of Programming languages
11
Basic concepts of Programming languages
Basic concepts of Programming languages:
6. Every language also defines certain symbols which are
permissible in that languages. The rules of using symbols as
per the given language are known as syntax rules for that
language.
7. The syntax rules are called the rules of the grammar for that
periocular language. The meaning of grammar is called
semantics.
8. Whenever we write any computer program we must follow
syntax rules for the programming language, which are using
for writing the computer program.
9. The computer system is simply a machine and hence it cannot
perform any work; therefore, in order to make it functional
different languages are developed, which are known as
programming languages or simply computer languages. 12
Basic concepts of Programming languages
1. Low-Level Languages:
➢ A low-level programming language interacts directly with the
registers and memory.
➢ Low level language does not require any compiler or interpreter to
translate the source to machine code.
➢ A computer cannot understand instructions given to it in high-level
languages or in English.
➢ It can only understand and execute instructions given in the form of
machine language i.e. binary.
➢ They are mostly used to develop operating systems, device drivers,
databases and applications that requires direct hardware access.
There are two types of low-level languages:
1. Machine Language or code
2. Assembly Language
13
Classification of Computer languages:
1. Machine Language or Code:
Machine language is called the language of the computer as computer
understands only this language which is a language consist of
sequence of 0’s and 1’s. This is the language that is written for the
computer hardware. Such language is effected directly by the central
processing unit (CPU) of a computer system.
Features of machine language:
➢ Consists of strings of 0’s and 1’s.
➢ Natural language of computer.
➢ Internally 0 and 1are converted into electrical signals.
➢ Each and every command or operation must be started in the form
of o and 1’s. They are machine depended.
➢ Execution of program is very fast as machine instructions are
directly understood by the commuter.
14
Classification of Computer languages:
Machine Language or Code:
Machine language is called the language of the computer as computer
understands only this language which is a language consist of
sequence of 0’s and 1’s. This is the language that is written for the
computer hardware. Such language is effected directly by the central
processing unit (CPU) of a computer system.
Features of machine language:
➢ Consists of strings of 0’s and 1’s.
➢ Natural language of computer.
➢ Internally 0 and 1are converted into electrical signals.
➢ Each and every command or operation must be started in the form
of o and 1’s. They are machine depended.
➢ Execution of program is very fast as machine instructions are
directly understood by the commuter.
15
Classification of Computer languages:
Advantages of Machine Language or Code:
➢ Programs written in machine language are executed very
fast(Immediate) by the computer. This is because the machine
Interactions (code) are understood by the CPU directly and no-
translation of the program is required.
➢ Machine language makes fast and efficient use of the computer.
➢ No translator is required. It requires no translator to translate the
code. It is directly understood by the computer.
➢ All operation codes have to be remembered
➢ All memory addresses have to be remembered.
16
Classification of Computer languages:
Machine Language or Code:
➢ Machine language makes fast and efficient use of the
computer.
➢ No translator is required. It requires no translator to
translate the code. It is directly understood by the
computer.
➢ Difficult to program , modify and error- prone.
➢ All operation codes have to be remembered
➢ All memory addresses have to be remembered.
17
Classification of Computer languages:
Disadvantages of Machine Language or Code:
➢ Machine Dependent
➢ Difficult to write programs
➢ Difficult to find errors
➢ Difficult to program modify
➢ All operation codes have to be remembered
➢ All memory addresses have to be remembered.
➢ Good knowledge of Computer hardware is essential
18
Classification of Computer languages:
2. Assembly Language:
➢ Assembly language, commonly called assembly ,asm or symbolic
code, is a human-readable notation for the machine that language
that specific computer architecture uses.
➢ Assembly language helps programmers to write the human-readable
code that is almost similar to machine language. Machine language
is difficult to understand and read as it is just a series of numbers.
Assembly language helps in providing full control of what tasks a
computer is performing.
➢ Machine language is a pattern of bits encoding machine operations,
is made readable by replacing the raw values with symbols called
mnemonics.
➢ It is a language of an encoding of machine code that makes simpler
and readable.
19
Classification of Computer languages:
Features of Assembly Language:
➢ Use of mnemonics to write programs which are small words specific
to machine to denote a specific operation like ADD,SUB, MUL
which represent operations addition, subtraction, multiplication
respectively.
➢ It can use mnemonic than numeric operation code and it also
provides the information of any error in the code.
➢ For writing programs set of mnemonics are made fixed for a specific
types of machine. The program are written using these mnemonics
but internally a translator called assembler convert them to machine
language form.
➢ Assembler is any system software which is specific for a specific
machine.
➢ Easy to understand and modify.
➢ Easy to locate and correct errors. 20
Classification of Computer languages:
Advantages of Assembly Language:
➢ It allows complex jobs to run in a simpler way.
➢ It is memory efficient, as it requires less memory.
➢ It is faster in speed, as its execution time is less.
➢ It is mainly hardware oriented.
➢ It requires less instruction to get the result.
➢ It is used for critical jobs.
➢ It is not required to keep track of memory locations.
➢ It is a low-level embedded system.
➢ Easy to understand and use
➢ Easy to find errors
➢ Efficiency increases
➢ No need to worry about addresses
21
Classification of Computer languages:
Disadvantages of Assembly Language:
➢ Machine Dependent
➢ Knowledge of hardware is essential
➢ Time Consuming. It takes a lot of time and effort to write the code
for the same.
➢ It is very complex and difficult to understand.
➢ The syntax is difficult to remember.
➢ It needs more size or memory of the computer to run the long
programs written in Assembly Language.
22
Classification of Computer languages:
3. High Level Language:
➢ High level languages are basically symbolic languages, which use
English words extensively and use the normal mathematical symbols
and functions rather than mnemonic codes.
➢ The high level language is simple and easy to understand For
example, COBOL, FORTRAN, BASIC, C, C+, Python, etc.
➢ High-level languages are very important, as they help in developing
complex software.
➢ Any higher level language has to be converted to machine language
for the computer to understand and for that a translator is required
which is specific for a specific high level language.
➢ High-level languages are programmer-friendly. They are easy to
write, debug and maintain.
➢ Each instruction in the high-level language is translated into many
machine language instructions that the computer can understand. 23
Classification of Computer languages:
Features of High Level Language:
➢ Program is written in simple English like language.
➢ Easy to understand and modify.
➢ Easy to locate and correct errors.
➢ High-level languages are similar to natural languages, therefore,
easy to learn and understand.
➢ High-level language is designed in such a way that it detects the
errors immediately.
➢ High-level language is easy to maintain and it can be easily
modified.
➢ High-level language makes development faster.
➢ High-level language is comparatively cheaper to develop.
➢ High-level language is easier to document.
24
Classification of Computer languages:
Advantages of High Level Language:
➢ Machine Independent: A program written in a high-level language
can be translated into many machine languages and can run on any
computer for which there exists an appropriate translator.
➢ High-level languages are user-friendly.
➢ They are similar to English and use English vocabulary and well-
known symbols.
➢ They are problem-oriented rather than 'machine'-based
➢ Easy to learn and use
➢ Easy to find errors
➢ Programming become Economic
➢ Good documentation
➢ Easy to maintain
25
Classification of Computer languages:
Disadvantages of High Level Language:
➢ It takes additional translation times to translate the source to machine
code.
➢ High-level programs are comparatively slower than low-level programs.
➢ Compared to low-level programs, they are generally less memory
efficient.
➢ A high-level language has to be translated into the machine language by a
translator, which takes up time.
➢ The object code generated by a translator might be inefficient compared
to an equivalent assembly language program
➢ Cannot communicate directly with the hardware.
26
Classification of High-Level Languages :
Many languages have been developed for achieving a variety of different
tasks. Some are fairly specialized, and others are quite general. High
languages are categorized according to their use, are:
1. Algebraic Formula-Type Processing: These languages are oriented
towards the computational procedures for solving mathematical and
statistical problems.
➢ BASIC (Beginners All Purpose Symbolic Instruction Code)
➢ FORTRAN (Formula Translation)
➢ PL/I (Programming Language, Version 1)
➢ ALGOL (Algorithmic Language)
➢ APL (A Programming Language)
2. Business Data Processing: These languages are best able to maintain
data processing procedures and problems involved in handling files.
Some examples include:
➢ COBOL (Common Business Oriented Language)
➢ RPG (Report Program Generator) 27
Classification of High-Level Languages :
3. String and List Processing: These are used for string manipulation,
including search patterns and inserting and deleting characters.
Examples are:
➢ LISP (List Processing)
➢ Prolog (Program in Logic)
4. Object-Oriented Programming Language: In OOP, the computer
program is divided into objects. Examples are:
➢ C++
➢ Java
5. Visual Programming Language: These programming languages are
designed for building Windows-based applications. Examples are:
➢ Visual Basic
➢ Visual Java
➢ Visual C
28
Other Types of Language
4. System languages: These are designed for low-level tasks, like
memory and process management like ALGOL and Pascal.
5. Scripting languages: These tend to be high-level and very
powerful. PHP, Perl, and Python are common examples of
scripting languages.
6. Domain-specific languages: These are only used in very
specific contexts. Examples:
DOT – A DSL to define graphs.
SQL – databases. ...
HTML – web layout.
7. Visual languages: Languages that are not text-based.
8. Esoteric languages: Languages that are jokes or are not
intended for serious use. Examples: Befunge, Brainfuck,
GolfScript, Whitespace etc.
29
Assembly Environment Setup
Assembly language is dependent upon the instruction set and the
architecture of the processor:
➢ An IBM PC or any equivalent compatible computer
➢ A copy of Linux operating system
➢ A copy of NASM assembler program
➢ There are many good assembler programs, like:
➢ Microsoft Assembler (MASM)
➢ Borland Turbo Assembler (TASM)
➢ The GNU assembler (GAS)
30
Language Processor/Translators
A language translator is a program which is used to translate an input
program written in one programming language into another
programming language (output program). Language translator is also
called a language processor. These system programs are used to convert
assembly/ High-level language program into machine code.
A program written in any high-level programming language is called
the Source code or program.
To convert the source code into machine code is called the object
code or program.
A Translator translates the source program into the object program
that the computer can understand and execute.
These special system programs accept the user program(source code)
and check each statement and, if grammatically or syntactically
correct, produce a corresponding set of machine language
instructions (object code.)
31
Language Processor/Translators
These special system programs accept the user program(source code)
and check each statement and, if grammatically or syntactically correct,
produce a corresponding set of machine language instructions (object
code.)
32
Types of Language translator /Processor
33
Assembler
A program written in assembly language can be converted into machine
language by a special types of system software called an “Assembler”.
We know that assembly language program is called source program or
source code and machine language program is called object program or
object code.
Assembler is a translator which is used to translate the assembly
language code into machine language code.
Assembly language is a low level programming language where we use
the symbols called mnemonics in place of machine codes. The
assembler performs a one to one mapping from mnemonic statement
into machine codes and data.
Assembly Machine
Language Language
Assembler
Program Program
(Source Code) (Object Code)
34
Assembler
How to run the Assembly language Program:
Assembly language is a system software. This inbuilt assembler
program is written by the high-skilled programmers and manufacturers
with great care. This program is copied into the memory by another
program called Loader/IPL(Initial Program Load). This loader is
stored in the memory.
35
Types of Assembler
I. Self Assembler
II. Cross Assembler
➢Self Assembler : It is also known as resident assembler ,which
runs on a computer for which it produces machine code, is called a
self assembler.
➢Cross Assembler: It is system software that runs on a computer
Other than for which it produces machine code. For example-
one pass Assembler and Two pass Assembler.
➢ One pass assembler : It reads the whole assembly language program
at one time only.
➢ Two pass Assembler: It reads the whole assembly language program
twice time only.
36
Assembler
Advantages of Assembler:
Assembler is Very fast translating assembly language to machine code as
1 to 1 relationship.
Efficiency in execution just like machine level language.
Disadvantages of Assembler:
Assembly language is difficult to understand. it is a low-level
programming language.
It is difficult to maintain.
37
Interpreter
It takes one statement of high- level language program and convert it
into machine code , which is immediately executed.
Interpreter converts the source program written in high level language
into machine languages.
An interpreter converts each statement of the program line by line into
machine code.
It means an interpreter translates the one line at a time into
machine language and executes it. Then moves towards the next line
this goes on till the end of the program.
If no error encounters. Interpreter stops and highlights the problem and
will not move to next line when any errors are encountered.
A interpreter requires a less storage space in primary memory than a
compiler.
38
How to Interpreter
It takes one statement of high- level language program and convert it
into machine code , which is immediately executed.
It means an interpreter translates the one line at a time into machine
language and executes it. Then moves towards the next line this goes on
till the end of the program.
39
Advantages and Disadvantages of Interpreter
Advantages of Interpreter:
Interpreter is that it makes easy to trace out and correct errors
in the source program.
Interpreters over compilers are that an error is found
immediately.
Disadvantages of Interpreter:
It is a time consuming process of translating and executing
statements one by one.
Programs execution is slow.
40
Compiler
A Compiler is the is a program that translates a high –level language
into machine language. It translates whole high-level language
program at once into machine language before it is executed.
Source programing a program written by a programmer in a high-level
language is called a source code program. After this source program
has been converted into machine language by a compiler. It is referred
to as an object program.
If source program contain errors, the compiler highlights a list of errors
at the end of the execution of the program. i.e. a compiler translates the
whole program before execution.
A compiler is a larger program and occupies more memory space. It is
costlier than interpreter.
41
Compiler
A Compiler is the is a program that translates a high –level language
into machine language. It translates whole high-level language
program at once into machine language before it is executed.
Source programing a program written by a programmer in a high-level
language is called a source code program. After this source program
has been converted into machine language by a compiler. It is referred
to as an object program.
If source program contain errors, the compiler highlights a list of errors
at the end of the execution of the program. i.e. a compiler translates the
whole program before execution.
A compiler is a larger program and occupies more memory space. It is
costlier than interpreter.
42
Compiler
43
Compiler
44
Difference between Compiler and Interpreter
S. No. Compiler Interpreter
A compiler takes the whole program as a single unit and Interpreter each line in translated or converted one by on
compiles it at once and executed
Translator program is required to translate the program Translator program is not required to translate the
6
each time you want to run the program. program each time you want to run the program.
More useful for commercial purpose More useful for learning purpose
9 Compiler are good for a very long program Interpreter is good for small programs.
Example :C compiler, PASCAL compiler, FORTRAN Example : Basic interpreter, Prolog interpreter, LISP, APL
0
compiler etc etc. 45
Advantages and Disadvantages of Compiler
Advantages of compiler:
Producers and executable file, and therefore the program can
be run without need of the source code.
A compiler converts a high-level program that can be executed
many times.
Disadvantages of compiler:
It is slow to execute as you have to finish the whole program.
It is not easy to debug as errors are shown at the end of the
execution.
46
Basic concepts of Programming languages
Assignment 1.
1. What is Language Processor?
2. What is Assembler?
3. What is Interpreter?
4. What is Compiler?
5. What is Low level Languages?
6. What is High level Languages?
7. What is Machine level Languages?
8. What is Assembly level Languages?
9. What is difference between Interpreter and Compiler?
10. What is Loader?
11. What is Linker?
47
Basic concepts of Programming languages
Assignment 2.
1. What meant by “Debugging”
2. What meant by “Mnemonics”
3. FORTRAN is used in which application area?
4. Explain the term FORTRAN, BASIC,COBOL and RPG
5. What is Source Code and Object Code?
6. How Machine language is machine Dependent?
7. What is Language Translator? Describe various types of translators
available.
8. What are the features of high-level languages? What feature are
required to make a Computer language more powerful tools?
9. What are the types of Computer Languages? Explain.
48
Basic concepts of Programming languages
Assignment 3.
1. What is difference between Assembler, Interpreter and Compiler?
2. What is Syntax and Semantic?
3. Which language use for business purpose? Explain about it.
4. Which language use for web applications? Explain about it.
5. Which language use for scientific purpose? Explain about it.
6. Which language is use for system programming purpose? Explain
about it.
7. What are the aims for studying concept of programming languages?
8. What is system Software?
49