COMPUTER PROGRAMMING|UNIT 1| REVIEW OF PROGRAMMING LANGUAGE

Review of programming concepts.

1.1 Definition

※Program;A program is a set of instructions that a computer uses to perform a specific function.

※Programming;Computer programming is a way of giving computers instruction about what they should do next.

a ※Programming language;Computer programming language is a language used to write computer program.

※Programming language;A computer programming language is a language used to write computer program Today programming language is human readable language. Nowadays there are millions of programming language are developed like;Q-basic,C,C++,Java.

1.2 Flowchart

※Flowchart;A Flowchart is a visual representation of the sequence of steps and decesions needed to perform a process.

Advantage of flowchart;

1)Flowchart are better way of commucating the logic of a system.
2)Flowchart act as a guide or blueprint during the SDLC(software development life cycle)
3)Flowchart help in debugging process.
4)FlowChart serve as a good program documentation.
5)The maintenance of operating program becomes easy with the help of flowchart.
6)flowcharts helps to detect deficiencies in the problem statement.

Disadvantage of flowchart;

1)Drawing a flowchart is time consuming.
2)Making changes in the flowchart is not an easy job.
3) If the logic of the problem is complex,the flowchart becomes complecated.
4)Flowchart can not be directly converted into program code.

Rules for designing a flow chart;

The American Standard Institute (ANSI), has recommended some general principles to help standardize the designing of a flowchart.
some of the rules and guidelines are as follows;

1)Always concentrate on the main logic of the problem.
2)After completing the main logic concentrate on the branches and loop.
3)Use only one start and stop point.
4)Avoid using computer language in a flowchart.
5)The terms used in the flowchart should be unambiguous, so that any programmer can easily understand the logic.
6) Flow lines should not cross each other.
7)The arrowheads direction of flow in any flowchart is from top to bottom or from left to right.

※Flowchart Symbols:A flowchart consists of simple geometrical symbols for differen functions.
Some of the basic flowchart Symbol are given below;


Symbol Purpose
The oval shaped Terminal Box is used to indicats the start and end of a flowchart.
The parallelogram shaped input/output box is used to show the input and output related steps in a flowchart.
The rectangle shaped processing box is used to show the processing step (calculations, data manipulate) in a flowchart.
The arrows that are used to connect the various geometrical symbols in flowchart are called flow lines.
The diamond shaped decision box is used to show the steps involving comparison and decision making steps.
The connectors indicates the continuation of the flow on another page.

1.3 Algorithm.

It is defined as a set of well defined steps for performing a task or solving a problem.

Advantage of an algorithm;

1)They are simple to understand.
2)Error can be pointed out easily. Debugging is simple.
3)They do not depend on any programming languages.
4)They are compatible with computer language.

Disadvantage of an algorithm;

1)Algorithm is time consuming.
2)Difficult to show Branching and Looping in algorithm.

Characteristics of an algorithm.

1)Unambiguous:-Algorithm should be clear and unambiguous.It must lead to only one meaning.
2)Input:-An algorithm should have one or more input.
3)Output:- An algorithm should have one or more output.
4)Finitness:- Algorithm must terminate after a finite number of steps.
5)feasibility:-Should be feasible with the available steps.
6)Independent:-It should be independent of any programming language.

Flowchart structure

There are three general flowchart structure;

1)Sequence structure.
2)Decesion structure.
3)Repetition structure.

※Sequence structure:→With a sequence structure, you can able to perform a task at a time and then next task in order. Once you start a series of actions in a sequence, you must continue step-by-step until the sequence end.

⚛ Write an algorithm and draw a flowchart to print the sum of two number.
Solutions;

step 1: Start
step 2:Read two numbers and store them in variable A and B.
step 3: Add A and B and store them in varable C.
Step 4: Display the value of variable
step 5: Stop

※Selection structure:→Selection structure allows execution of one of the two alternative paths depending on a condition.This structure is also called Decision structure because it helps in making decision about which set of statement is to be executed.

⚛ Write an algorithm and draw a flowchart to print the greatest number among two number.
Solution;

Algorithm;

stept 1: Start
Step 2: Read two numbers and store them in variables A and B.
Step 3: Compare A and B.If A is greater than B then print A otherwise print B.
Step 4:Stop.

Flowchart;

※Repetition structure:→The repetidion structure allows to repeat an operation or a set of operations as long as the condition is true.The iteration structure is also called looping structure. There are two types of repetition structures: Pre-test repetition structure and post-test repetition structure. A pre-test structure tests its condition before it performs an action. A post-test structure tests its condition after it performs an action.

⚛Write an algorithm and draw a flowchart to print the first ten natural numbers.
Solutions;

Algorithm;

Step 1: start
step 2: Initialize the variable count to one.
step 3: Display the variable count.
step 4: Increment the variable count by one.
step 5: check whether variable count exceeds 10.
{If yes, goto step 3.
If no,go to step 6}
Step 6:Stop.

Flowchart;

1.4 Pseudocode

※Pseudocodo code:→It's simply an implementation of an algorithm in the form of annotations and informative text written in plain English.It has no Syntax like any of the programming language and thus can't be compiled or interpreted by the computer.

Advantages of Pseudocode are;

1)Improves the readability of any approach.
2)Acts as a bridge between the program and the algorithm or flowchart.
3)The main goal of a pseudocode is to explain what exactly each line of program Shoud do, hence making the code construction phase easier for the programming.

Disadvantage of Pseudocode;

1)There are no accepted standards for writting pseudocodes and designer use their own style while waiting pseudocode.
2)Pseudocode can not be compiled and excuted so its correctness can not be a verified by using computers

Rules for designing Pseudocode:

1)Arrange the sequence of tasks and write the Pseudocode accordingly.
2)Start with the statement of a pseudocode which establishes the main goal of the aim.
3)Use control structure.
4)Use appropiate naming conventions.
5)Use appropriate sentence casings, such as Add/Two Number for methods, Upper case for constants and lower case for variables.
6)Elaborate everything which is going to happen in the actual codes.
7)Use the standard Programming Structures such as "if" "then" "for" "While" "Cases" the way we use it programming.
8)Check whether all the sections of a pseudocode is complete, finite and clear to understand.
9)Don't write the pseudocode in a complete programmatic manner.

⚛How to Write a Pseudocode to find the sum of given two numbers.
Solution;

BEGIN
WRITE" Please enter two number to add"
READ num1
READ num2
Sum = num1 + num2
WRITE Sum
END

New paradigm of programming language;

※paradigm of programming Language:Programming paradigm is way of doing programming.
There are some programming paradigm as follows;

1)Imperative programming paradigm;
It is one of the oldest programming paradigm. In this paradigm the task is completed by changing its state step-by-step. It is machine oriented like;C,C++ and Java.

2)Declarative programming paradigm;
In this paradigm, the main logic is specifying the result you want not how to get it. Like; Prolog, mercury,Database management etc.

3)Structured programming paradigm;
In this approach a huge task is separated by small module to perform any task.

4)Procedure pprogramming Paradigm;
In this approach a task is completed step-by-step without changing it's state Like;Cobol, FORTRAN,ALGOL,C.

5)Object oriented programming paradigm;
In this approach a huge task is done by creating class and Obiect.It empasis on data rather than procedure. Like;C++ and Java.

6)Logic programming paradigm;
It is normally based on formal logic.In this approach the statement are written in the form of logic of series like; prolog.

7)Funtional programming paradigm;
In this a paradigm a mathematical operations are done with the help of funtion like javascript.

8)Database;
This programming paradigm based on data and it's movement.

9)Event driven approach;
In this paradigm it is used in hardware description language. It depends on even like mouse click , key press. Like;java,Php,Python used In this paradigm.

Difference between Object-Oriented and event driven approach;

Object-Oriented Event driven approach
It is emphasis on object rather than actions It is a programming paradigm in which the flow of the program is a determined by events such as user action(mouse click, key press)
It is based on execution of programs by invoking methods of object. It is based on execution by listening events.
Example;C++, java, Python etc. Example; javascript.

Previous
Next Post »

Watermark free kinemaster

DOWNLOAD