Introduction to Programming

~ dimanche 5 juillet 2015


Computer Programming– A program has a set of instructions written in correct order to get the desired result. The method of writing the instructions to solve the given problem is called programming.

Programming languages can be divided into two categories:

(i)                Low Level Languages or Machine Oriented Languages: The language whose design is governed by the circuitry and the structure of the machine is known as the Machine language. This language is difficult to learn and use. It is specific to a given computer and is different for different computers i.e. these languages are machine-dependent. These languages have been designed to give a better machine efficiency, i.e. faster program execution. Such languages are also known as Low Level Languages. Another type of Low-Level Language is the Assembly Language. We will code the assembly language program in the form of mnemonics. Every machine provides a different set of mnemonics to be used for that machine only depending upon the processor that the machine is using

(ii)             High Level Languages or Problem Oriented Languages: These languages are particularly oriented towards describing the procedures for solving the problem in a concise, precise and unambiguous manner. Every high level language follows a precise set of rules. They are developed to allow application programs to be run on a variety of computers. These languages are machine-independent. Languages falling in this category are FORTRAN, BASIC, PASCAL etc. They are easy to learn and programs may be written in these languages with much less effort. However, the computer cannot understand them and they need to be translated into machine language with the help of other programs known as Compilers or Translators.

Programming techniques: - There are two type of programming techniques commonly used:-
1.      Procedural Programming
2.      Object Oriented Programming (OOP)

Procedural Programming– In Procedural Programming, for a given problem, variables are identified and instructions are written using the variables in the correct sequence to get the required result.
                        The procedural Programming method is commonly used to solve scientific and engineering problem involving variables.

Object Oriented Programming (OOP)– In Object Oriented Programming, Objects which have data related to a person or item are used. The program can be written using many functional blocks. The functional block contains instructions similar to procedural programming.
                        Object Oriented Programming method is commonly used to develop software packages. C++ is one of the commonly used object oriented programming languages.

Algorithm – In order to write computer programs without any logical errors, it is recommended programmers prepare a rough writing showing the steps involved in the program. This is called an algorithm.
                        An algorithm presents step by step instructions required to solve any problem. These steps can be shown diagrammatically using a flowchart.


Flowchart – Flowchart is a symbolic or diagrammatic representation of an algorithm. It uses several geometrical figures to represent the operations, and arrows to show the direction of flow. Following are the commonly used symbols in flowcharts:-

(Click on image for large view)


Question – Answer

Q. 1 Write the algorithm and draw the flowchart to find the sum and product of given two numbers.

Solution:

            In this problem, two numbers, Let A and B, are given (input) and the result, sum (A+B) of two numbers and product (A*B) of two numbers, are to be calculated.

Algorithm:
1.      Read a, b
2.      Sum ← a+b
3.      Product ←a*b
4.      Print sum, product
5.      Stop

Flowchart:

Note – We can use equal to (=) sign instead of arrow (←). E.g. sum = a+b

Video Tutorial Click Below:



Like it ? Share it.

0 commentaires :

Enregistrer un commentaire