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 = L0 (First number)
For each item in the list
do
If the item
Largest,

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
Running a Program



Programming Languages
- BASIC
- C
- C++
- COBOL
- FORTRAN
- Ada
- Pascal
- Low-level Language
- High-level Language

Low-level Language
High-level Language
- Use natural language elements.
- Be easier to use.
- Be from the specification of the program.
Problem-oriented Languages

Procedural Languages

Non-Procedural Languages

Scripting Languages

No comments:
Post a Comment