Ch-2 Programming Basics
Ch-2 Programming Basics
CHAPTER-2
PROGRAMMING BASICS
Chaitsi Desai
Computer Educator
Introduction to Programming
■ Computer understand only one language that is machine language.
■ The set of instructions written in a language which a computer can understand is called a program.
■ Computers solve problem in a step by step procedure to give you accurate result.
■ An algorithm and flowchart help us to create a computer program in step by step manner.
1. Algorithm
2. Making flowchart
3. program
Algorithm
■ An algorithm is a step by step procedure to solve any particular task.
■ Let us understand it by an example what step would you follow to buy a shirt
2. Tell the shopkeeper which color and style of shirt you want
Step1: Start
Step5: Stop
Example for Algorithms
■ Write an algorithm to find greater number of the two:
Step1: Start
Step2: Take two Numbers A and B
Step3:Compare two numbers; if A>B, then goto Step4 or else goto Step6
Step4:Print A is Greater
Step5: Stop
Step6: Print B is Greater
Step7: Goto Step5
Flowchart
■ A flowchart is a diagrammatic representation of algorithms.
■ Herman Goldstine and John Von Neumann develop the flowchart to plan computer
programs
■ These symbols are connected to each other by arrows to show the operations .
Symbols used for Flowchart
Advantages of flowchart
■ Flow chart help in analyzing the problem in a more effective way
■ It is the better way of communicating the logic of system
■ It act as a guide during the program development phase
■ It helps in finding out errors.
Disadvantages of flowchart
■ Sometimes the flowchart become complex is a program logic is long.
■ If you want to change something in the flowchart you have to redraw it
Program
■ It is difficult for a programmer to write their programs directly in terms of these digits.
■ Therefore some other computer languages have been developed in which writing program
have become easier.
■ It consists of a set of words, symbols, and a code that is used to write a program.
– Machine language
– Assembly language
Machine language
■ A program written in assembly language use short sequence of letters called mnemonic codes Like
ADD for addition, CMP for comparison, LDA for loading and MUL for multiplying
■ Assembly language program is the source program which must be translated into a machine language
before a computer can understand it.
■ An assembler is a program used to translate assembly language into a machine language so that
computer can understand it.
High Level Languages
■ High level language has instructions which are almost similar to English language
used by us.
■ Interpreter and Compiler are the two program used to translate high level
language into machine level language.
Procedural Language
■ Procedural language is also called the Third Generation language.
■ In this language the programmer writes instructions that tell the computer what to accomplish and how to
do it.
■ This language uses English like words to make it easy for programmers to write the program.
■ Third generation language is also use arithmetic operators such as * for multiplication and + for addition.
■ The 3GL is also called the source program, which must be translated into a machine language before
the computer can understand it.
■ In this language the programmer only specifies what the program should accomplish without explaining how.
■ 4GLs are easy to use, that users with very little programming background can develop programs using fourth
generation language.
■ It is also a source program which must be translated to machine language with the help of a compiler or
interpreter.
■ This is the type of query language that allows the user to enter requests that resemble
human speech.
■ Natural languages are opened associated with expert systems and artificial
intelligence.
Language Processor
■ Language processor is a software that convert source program into machine language.
■ Because it understands only machine language.
Compiler:
■ A compiler converts the entire HLL program into machine language at once.
■ And display errors for the whole program together.
Interpreter:
■ Interpreter converts one line of program at a time.
■ It displays error of one line at a time and goes to next line only after correction of that error.
THANK YOU!!!