Thursday, 13 April 2017

Programing

Programming
A set of instructions that tells the computer how to behave, what to do, and derives a solution to a particular problem is known as a program.
A program is written to solve a specific problem.
Example:2+2;
A program is a set of instructions telling a computer exactly what to do.
For example we can ask a computer to add 2 and2.
A program is written in a language that a computer can understand.
It provides a sequence of instructions to the computer.
Algorithms 
An Algorithm is a well-defined procedure that allows a computer to solve a problem.
Example:
Finding the largest number in an unsorted list of numbers:
Steps
Description
Input
A non-empty list of numbers L
Output
The largest number in the list
Algorithm
Let Largest = L(First number)
    For each item in the list
do
If the itemLargest,
Then Largest the item
Return Largest
What is Pseudo Code? 
A compact and informal high-level description of a computer programming algorithm that uses the structural conventions of a programming language.
Pseudo code = English, but looks like programming.
Contains only instructions that have a well-defined structure and resemble programming languages.
Flowchart
Used to graphically represent an algorithm or a program.
Flowchart Symbols 
Example:
Programming Language 
A programming language specifies the words and symbols that we can use to write a program.
A programming language employs a set of rules that dictate how the words and symbols can be put together to form valid program statements.
The mechanics of developing a program include several activities:
Writing the program in a specific programming language (such as Java)
Translating the program into a form that the computer can execute.
Investigating and fixing various types of errors that can occur.
Software tools can be used to help with all parts of this process.
Levels of Programming Languages 
Machine Language:
The set of symbolic instruction codes usually in binary form that is used to represent operations and data in a machine (as a computer) —called also machine code.
Machine dependent.
Each type of CPU (Central Processing Unit) has its own specific machine language.
Each instruction is a binary string.
The code is used to indicate the operations to be performed and the memory cells to be addressed.
This form is the easiest for computers to understand, but is most difficult for a person to understand.
Assembly Language:
Machine dependent.
English-like abbreviations representing elementary computer operations (translated via assemblers).
Example:
LOAD 2
ADD 2
DISPLAY SUM
High-Level Language:
Machine independent.
Compilers translate High-Level Languages to machine languages.
Example: 
C, C++, FORTRAN
Compiler and Interpreter
A compiler is a software tool which translates source code into a specific target language.
A program must be translated into machine language before it can be executed.
An Interpreter executes programming codes line by line, rather than the whole program.
Phases of a C Program 
Pha
Description
Edit
Program is created in the editor and stored on disk
Preprocess
A preprocessor program processes the code
Compile
A compiler creates object code and stores it on disk
Link
A linker links the object code with the libraries
Load
Loader puts the program in memory
Execute
CPU takes each instruction and executes it
Variables 
Named memory locations that can store values.
Think of it as a box in which you can store a value and retrieve a value.
Example:
Steps for Writing a Program 
Understand the problem you are trying to solve.
Design a solution.
Draw a flow chart.
Write pseudo code.
Write code.
Test.
Test with real world users.
Release program.
Iterate above steps for next version.


Computer Programming



  • Computer Programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs.


  • This source code is written in one or more programming languages.



  • Running a Program 



  • Converting a human readable program into machine language:


  • Compilation and execution of code:


  • Interpretation of a program:



  • Programming Languages 



  • The term programming language usually refers to high-level languages, such as:
    • BASIC
    • C
    • C++
    • COBOL
    • FORTRAN
    • Ada
    • Pascal


  • Each language has a unique set of keywords and a special syntax for organizing program instructions.


  • Types of programming languages:
    • Low-level Language
    • High-level Language



    Low-level Language



  • A Low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture.


  • Generally, this refers to either machine code or assembly language.



  • High-level Language 



  • A computer language whose instructions or statements correspond to several machine language instructions, designed to make coding easier.


  • A High-level programming language is a programming language with strong abstraction from the details of the computer.


  • As opposed to lower level languages, higher level languages may:
    • Use natural language elements.
    • Be easier to use.
    • Be from the specification of the program.


  • This makes the process of developing a program simpler and more understandable.



  • Problem-oriented Languages



  • A language whose statement resembles the language of the user is called Problem-oriented language.



  • Procedural Languages



  • In procedural programming, programs follow a structured set of steps (a procedure).



  • Non-Procedural Languages 



  • Visual Basic and Java are called Non-procedural or Event-driven languages.


  • Instead of writing a series of sequential instructions, a programmer defines the actions that the program must perform when certain events occur.



  • Scripting Languages 



  • Scripting languages, which can be embedded within HTML, are commonly used to add functionality to a Web page, such as different menu styles or graphic displays or to serve dynamic advertisements.



  • Object Oriented Programming 

    No comments:

    Performance measures of computer

    Computer education point PERFORMANCE MEASURES : In this section, we consider the important issue of assessing the performance of a comput...