SCHOOL QUESTIONNAIRE

SCHOOL QUESTIONNAIRE
Education in continuing a proud tradition.

PROGRAMMING BASICS TECHNOQUES

 PROGRAMMING TECHNIQUES

👉Learning Plan

After complete reading this, you will be able to:

  1. Describe the most commonly used techniques in programming.

 2. Define algorithm and state the features of an algorithm.

 3. List the advantages and disadvantages of using a flowchart. 

 4. Explain the rules for designing a flowchart.

 5. Explain the three main types of flowchart.

👀Introduction

Today, computers are used in different fields to solve problems. Computer needs a program to solve a specific problem. Writing a computer program is a very tedious and complex task. The programmers should have a clear and sufficient knowledge about the problems and the logic of the program. A programmer solves different problems using different techniques. Each technique has its own merits and demerits. Methods used to develop a solution or a program are called programming techniques. The programmers use different techniques to develop the logical sequences for the solution of the problem.

Some of the most commonly used techniques in programming  are
a. Algorithm
b. Flowchart
c. Pseudocode

Algorithm
An algorithm(pronounced AL-go-rith-um) is a procedure or formula for solving a problem. After preparing the algorithm, one must recheck it so as to ascertain the accuracy of the various steps involved. the number of steps in an algorithm should be reduced to a minimum so as to increase the speed of the program.

Properties of an Algorithm
The algorithm should have the following properties:
a. It should have an input.
b. The steps mentioned in a an algorithm should be in the simple language.
c. Each and every instruction should be in a simple language.
d. The number of steps should be finite.
e. It should not depend on a particular computer language or computer.
f. The algorithm should give an output after executing the finite numbers of steps.

Advantages of an Algorithm
The advantages of an algorithm are listed below:
a. An algorithm simplifies the overall task by dividing it into simpler tasks.
b. An algorithm is written so that the code may be written in any language.
c. An algorithm is written in an English like manner.
d. Every step in an algorithm has own logical sequence so it is easy to debug.
e. An algorithm uses a definite procedure.

Solved Examples
Write an algorithm to find make a telephone call to your friend.
Solution:
Step 1 : Start
Step 2 : Read the telephone number from the directory or diary.
Step 3 : Lift the receiver.
Step 4 : Is there a dial tone?
             If yes, then dial the number.
             If no, then put down the receiver and go to step 2.
Step 5 : Speak to your friend.
Step 6 : Put down the receiver
Step 7 : Stop

Write an algorithm to find area of a rectangle.
Solution:
Step 1 : Start
Step 2 : Read length(L) and breadth(B) and store them as L and B.
Step 3 : Multiply by L and B and store it in area.
Step 4 : Stop

Write an algorithm to calculate the factorial of a number(N). 
Solution:
Step 1: Start
Step 2: Read N
Step 3: Factor = 1
Step 4: Counter = 1
Step 5: While (Counter N)
            Repeat steps 4 through 6
Step 6 : Factor =Factor * Counter
Step 7 : Counter +1
Step 8 : Print (N, Factor)
Step 9 : Stop

Write an algorithm to find the greatest number among three numbers.
Solution:
Step 1 : Start
Step 2 : Read three numbers and store them in A, B and C.
Step 3 : Compare A and B. If A is greater than B then go to step 6 else step 4.
Step 4 : Compare B and C. If B is greater than C then print "B is greatest" and go to step 8 otherwise go to step 5.
Step 5 : Display " Cis greatest" and go to step 7.
Step 6 : Compare A and C. If A is greater than C then display A is greatest and go to step 8 otherwise go to step 7.
Step 7 : Display "C is greatest" and go to step 8.
Step 8 : Stop

Flowchart

Flowchart is a graphical representation of a process or system that details the sequencing of steps required to create output. A typical flow chart uses a set of basic symbols to represent various functions, and shows the sequence and interconnection of functions with lines and arrows. The process of drawing a flowchart is known as flowcharting.

Advantages of Flowchart
a. It is a convenient method of communication.
b. It indicates very clearly just what is being done, where as program has logical complexities.
c. It saves the inconveniences in future and serves the purpose of documentation for a system.
e. It provides an overview of the system and also demonstrate the relationship between various steps.

Disadvantages of flowchart
a. Flowchart is a waste of time and slow down process of software development.
b. Flowchart is quite costly to produce and difficult to use and manage.
c. As the flow chart symbols cannot be typed, reproduction of flow chart becomes a problem.

Flowcharting design Guidelines
The following are some guidelines in flowcharting:
a. Concentrate on the main logic of the problem.
b. After completing the main logic, concentrate on the branches and loops.
c. Use only one start and stop point.
d. Avoid using computer language in a flow chart.
e. The terms used in the flowchart should be unambiguous, so that any programmer can easily understand the logic.
f. Flow lines should not cross each other.
g. The arrowheads are used to indicate the direction of flow of control in the problem. The general direction of flow in any flowchart is from top to bottom or from left to right.
h. The connectors joining the different pages must be adequately referenced while drawing a flow chart on more than one sheet of paper.

Flowchart Symbols

fig : Symbols with their respective meanings.

Solved Examples
Draw a flowchart to accept two numbers and display their sum.
Solution:


Fig: Flowchart 
Draw a flowchart to accept three numbers and display the greatest number among them.
Solution: 

Fig: Flowchart Showing Greatest Among Three Numbers.

Pseudocode

Pseudocode is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations. It is used for creating an outline or a rough draft of a program. Pseudocode summarizes a program's flow, but excludes underlying details. System designers write pseudocode to ensure that programmers understand a software project's requirements and align code accordingly.

Advantages of Pseudocode
a. Pseudocode can be read and understood easily.
b. Pseudocode enables the programmer to concentrate only on the algorithm part of the code development.
c. Pseudocode cannot be compiled into an executable program.


Post a Comment

0 Comments