C programming|Unit 1 Programming Language

1.1 Definition

Program

Program is a set of well defined instuction that solve some particular task.

Programming

Programming is the process of writing computer program by computer programmer.

Programming Language

Programming language is the language which is used to write the computer program.

1.2 History of programming language

  1. 1843
  2. Ada Lovelace's machine algorithm.
    It was the first concept of computer programming concepts by Lady Augusta Ada Lovelace.
    The main purpose this programming concepts is to calculate any task by the precise instruction.
  3. 1944 to 1945
  4. plankalkul
    It was developed by Konrad Zuse.
    It the first real programming language.
    It is mostely used in mathematical operation like algebric expression.
    First high level programming language.
  5. 1949
  6. Assembly language
    It was developed by David Wheeler.
    Assembly language was used in the electronic delay storageautomatic calculator.
  7. 1952
  8. Autocode
    It was developed by Alick Glennie for the mark-1 computer.
    It is simplified programming language and is compiler implementation language.
  9. 1957
  10. FORTRAN.
    It was developed by John Backus.
    It is normally used in numerical,scientific and computing.
  11. 1958
  12. ALGO(Algorithmic Language)
    It was developed by Joint committee of American and European computer scientists.
    It served as the starting point for the developement of some of the most important programming language icluding pascal,c c++ and JAVA.
  13. 1958
  14. LISP
    It was developed by John McCarthy at the Massachusetts Institute of Technology.
    It is generally used in Artificial Intelligence.
  15. 1959
  16. COBOL(Common Business Oriented Language)
    It was developed by Dr.Grace Murray Hoppert.
    It is normally used in banking sector for business purpose.
  17. 1964
  18. BASIC(Beginner's All Purpose Symbolic Instruction Code).
    It was developed by a group of students at Darmouth college.
    The main purpose this programming was written for the students who did not have a strong understanding of mathematics or computers.
  19. 1970
  20. PASCAL
    It was developed by Niklaus Wirth.
    It is mainly used to teach Structure programming institution to programming beginners.
  21. 1972
  22. Smalltalk
    It was developed at the Xerox Palo Alto Research center by Alan Kay,Adele Goldberg, and Dan Ingalls.
    It is commonly used for system programming like US. military type project.
  23. 1972
  24. C
    It was developed by Dennis Ritchie at the Bell Telephone Laboratories.
    It was first developed to make unix operating system.

Generation of programming Language

There are five generation of programming language.
1.First Generation(1946 to 1958)
First generation program are written in machine language .These are low level language like machine language.These are used primarily for very limited sientific and engineering problems.
2.Second Generation(1959 to 1964)
These are low level assembly language. It was machine-independent language generally used mnemonics for easy understanding by programmer.
3.Third generation(1965 to 1974)
The high level language as developed in this generation like c,c++, java etc. It is human readable code.
4.Forth generation(1975 to 1990)
These are languages that consists of statements that are similar to statements in the human language. These are used mainly in database programming and scripting.Examples of these language include perl,python,ruby,SQL, MatLab(MatrixLaboratory).
5.Fifth Generation(1990 to present)
These are the programming Languages that have visual tools to developed a program.Examples of fifth generation language include mercury,and prolog.

1.3 Classification Of Programming Language

1.3.1 Machine Language


Machine Level Language is the native language of the computer. Machine Level language statement are written in binary codel (0 or 1).

Merits of machine language;

1)It requires less time during program execution.
2)It is more secure.
3) Program written in the form of O and 1 that is machine language that's why it not require language translator.
4)Computational spoed is very fast.

Demerits Of Machine Language;

1)A Development of writting a program is time consuming.
2)It is machine dependent i.e. individual machine require individual coding.
3)It is very hard to understand the program.
4)It is not portable.

1.3.2Assembly Language
A low level language that permits the use of mnemonics for each instruction that the machine can do. Programs written in assembly language is not directly understand by machine that's why assembler need to convert mnemonics code into machine code.

Merits of Assembly Language;

1)It is easily understand by human because it uses mnemonics rather than binary digits.
2)It require less time to developed computer program.
3)Debugging is easy.
4)Easier to modify.

Demerits of Assembly Language;

1)It needs hardware implementation knowledge.
2)Program are machine dependent.
3)Less efficient than machine Language.
4)Statement are not like english.

1.3.3 High Level Language:-The Language which is closer to human language so it is more easy to write code in high level language.

Merits of high level language;

1)Easy to use and understand.
2)It is portable language.
3)Debugging process is easy.
4)It is easy to maintain.

Demerits of high level language;

1)Execution time is slow.
2)programmer do not control the hardware resources like registers, interrupts.etc
3)Additional Software is required.
4)Less memory efficient.

1.3.4 Fourth Generation Language
It is a programming environment designed with a specific purpose in mind. such as the development of commercial business software. It is closer to human language. It is designed to reduce programming effort and the cost of software development.Like Database management system software.

Merit of fourth generation language;

1)It is easy to learn.
2)It is easy to debug.
3)Less time to developed a program.
4)It is more portable.

Demerits of fouth Generation Language;

1)It's execution time is slower.
2)need more space in memory.
3)It is require technical skill to write fourth generation language.
4)Require higher specification software and hardware to code in UGL.

1.3.5 Fifth Generation Language

Fifth generation language are programming languages that contains visual tools to help develop a program. Fifth generation languages are used mainly in artificial intelligence research.Like;prolog and mercury.

Merits of fifth Generation Languages;

1)They will be able to recognize image and graphs.
2)They aim to be able to solve highly complex problem including decesion making logical reasoning.
3)It work with natural language.
4)It behaves like human being.

Demerits of fifth generation language;

1)It take more memory space.
2)This programming language executes Slowly.
3)Less memory of efficient.
4)Skill developed Technician required.

1.5Compiler,Interpreter and assembler

Compiler:-Compiler is computer software program which translate high level programming into machine code.

Interpreater:-It is a computer program that can analyse and execute a program line by line.

Assembler:-An assembler is a computer program that convert Assembly language written code into machine code.

Differentiate between Compiler and Interpreater

Compiler Interpreater
It checks the entire program as whole It checks the program line by Line.
More Memory required Less memony require
Error are display after entire program is checked Error check line by line
Example: C compiler Example:Qbasic

1.6 List of High level programming;

There are some high level programming language listed below;
1)C:–unit operating system.
2)JAVA:-Internet
3)PHP:-web development
4)Visual Basic--Desktop application.
5)python:–Hacking
6)Asp.net:-web application
7)C#:-Desktop application
8) Javascript - Scripting

1.7 Difference between program and software;

Program Software
Set of well defined instruction collection of program.
Less functionality large functionality
Design for personal use Design for company
Lack of user Interface Good User Interface

1.8 Concept of programming statement program statement;

Programming statement:- Every command or insrauction in computer programming is known as programming statement.

1.9 Syntax and Semantics error:

Syntax error:-The error which occur in programming language statement is called Syntax error.

Semantics error:-The error which occurs in execution time is called semantics error.

※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.

2.0 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.

2.1 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;

2.2 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

Previous
Next Post »

Watermark free kinemaster

DOWNLOAD