0% found this document useful (0 votes)
3 views4 pages

COS201 Lecture 1

The document provides an introduction to computer programming, defining key concepts such as programs, programming languages, markup languages, and scripting languages. It discusses various programming paradigms, classifications of programming languages, and the characteristics and writing of algorithms. Additionally, it emphasizes the importance of algorithms in guiding programmers to solve problems effectively.

Uploaded by

wwwtope947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

COS201 Lecture 1

The document provides an introduction to computer programming, defining key concepts such as programs, programming languages, markup languages, and scripting languages. It discusses various programming paradigms, classifications of programming languages, and the characteristics and writing of algorithms. Additionally, it emphasizes the importance of algorithms in guiding programmers to solve problems effectively.

Uploaded by

wwwtope947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ACHIEVERS UNIVERSITY, OWO

COLLEGE OF NATURAL AND APPLIED SCIENCES


DEPARTMENT OF COMPUTER SCIENCE
COS 201 – COMPUTER PROGRAMMING I – 3 UNITS

LECTURER IN CHARGE - MR. ADEPOJU, S. E.

LECTURE 1

INTRODUCTION
What is a Program?
A computer program is a list of instructions that tell a computer what to do. Everything a
computer does is done by a computer program. A computer program is a sequence or set of
instructions in a programming language for a computer to execute. A computer program in its
human-readable form is called source code. A computer program can also be defined as a finite
sequence of instructions that a computer follows to solve a particular problem.

What is Programming?
Computer programming is the process of designing, writing(coding), testing, debugging and
maintaining the source code of computer programs.

What is Programming Language?


A programming language is a formal set of notations and rules designed to connect instructions
to a machine or a computer. Programming languages are mainly used to control the performance
of a machine or to express algorithms. At present, thousands of programming languages have
been implemented. In the computer field, many languages need to be stated in an imperative
form, while other programming languages utilize declarative form. The artificial languages that
are used to develop computer programs are called programming languages. Examples are Java,
C, C++, C#. Programming languages are most widely used to make software or drivers.

Markup Language
Markup languages prepare a structure for the data or prepare the look or design of a page. These
are presentational languages and it doesn’t include any kind of logic or algorithm, for example,
HTML. HTML is not asking any kind of question to the computer or it’s not comparing things
and it’s not asking any logical question. It’s just used to represent a view inside a web browser. It
tells the browser how to structure data for a specific page, layout, headings, title, table and all or
styling a page in a particular way. So basically it involves formatting data or it controls the
presentation of data. Examples of Markup languages are HTML, CSS or XML. These languages
are most widely used to design a website.

Scripting Language
As the name suggest, it’s all about giving the script to perform some certain task. Scripting
languages are basically the subcategory of programming languages which is used to give
guidance to another program or we can say to control another program, so it also involves
instructions. It basically connects one language to one another languages and doesn’t work
standalone. JavaScript, PHP, Perl, Python and VBScript, these all are the examples of scripting
language. Scripting languages need to be interpreted (Scanning the code line by line, not like
compiler in one go) instead of compiled. There is no scope of compiler in scripting languages.
Scripting languages are most widely used to create a website.

Programming Paradigm
A paradigm is the preferred approach to programming that a language supports. A
programming paradigm is a relatively high-level way to conceptualize and structure the
implementation of a computer program. A programming language can be classified as supporting
one or more paradigms.

Classification of Programming Languages


1. Imperative Programming: Code directly controls execution flow and state change, explicit
statements that change a program state.
(a) Procedural: It involves implementing the behavior of a computer program as procedures
(a.k.a. functions, subroutines) that call each other. The resulting program is a series of
steps that forms a hierarchy of calls to its constituent procedures. Examples procedural
programming language are Fortran, ALGOL, COBOL, Pascal and C
(b) Object-oriented: Organized as objects that contain both data structure and associated
behavior, uses data structures consisting of data fields and methods together with their
interactions (objects) to design programs. In attempt to improve on procedural languages,
object-oriented programming (OOP) languages were created, such as Simula, Smalltalk,
C++, Eiffel, Python, PHP, Java, and C#. In these languages, data and methods to
manipulate the data are in the same code unit called an object.

2. Declarative Programming: Code declares properties of the desired result, but not how to
compute it, describes what computation should perform, without specifying detailed state
changes compared to imperative programming.
(a) Functional: It is paradigm where one applies pure functions in sequence to solve
complex problems. A desired result is declared as the value of a series of function
evaluations. Examples are Haskell, SML, Lisp and Scheme.
(b) Logic: It is a programming, database and knowledge representation paradigm based on
formal logic. A logic program is a set of sentences in logical form, representing
knowledge about some problem domain. Examples include Prolog, Answer Set
Programming (ASP) and Datalog.
Note: Structured programming is a programming paradigm aimed at improving the clarity,
quality, and development time of a computer program by making extensive use of the structured
control flow constructs of selection (if/then/else) and repetition (while and for), block structures,
and subroutines. Examples include ALGOL 58 and ALGOL 60.

Algorithm
Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a
certain order to get the desired output. Algorithms are generally created independent of
underlying languages, i.e. an algorithm can be implemented in more than one programming
language.
From the data structure point of view, following are some important categories of algorithms −
● Search − Algorithm to search an item in a data structure.
● Sort − Algorithm to sort items in a certain order.
● Insert − Algorithm to insert item in a data structure.
● Update − Algorithm to update an existing item in a data structure.
● Delete − Algorithm to delete an existing item from a data structure.

Characteristics of an Algorithm
Not all procedures can be called an algorithm. An algorithm should have the following
characteristics
● Unambiguous − Algorithm should be clear. Each of its steps (or phases), and their
inputs/outputs should be clear and must lead to only one meaning.
● Input − an algorithm should have 0 or more well-defined inputs.
● Output − an algorithm should have 1 or more well-defined outputs, and should match the
desired output.
● Finiteness − Algorithms must terminate after a finite number of steps.
● Feasibility − should be feasible with the available resources.
● Independent − an algorithm should have step-by-step directions, which should be
independent of any programming code.

How to Write an Algorithm?


There is no well-defined standards for writing algorithms. Rather, it is problem and resource
dependent. Algorithms are never written to support a particular programming code.
As we know that all programming languages share basic code constructs like loops (do, for,
while), flow-control (if-else), etc. These common constructs can be used to write an algorithm.
We write algorithms in a step-by-step manner, but it is not always the case. Algorithm writing is
a process and is executed after the problem domain is well-defined. That is, we should know the
problem domain, for which we are designing a solution.
Example
Let's try to learn algorithm-writing by using an example.
Problem − Design an algorithm to add two numbers and display the result.
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 – STOP

Algorithms tell the programmers how to code the program. Alternatively, the algorithm can be
written as −
Step 1 − START ADD
Step 2 − get values of a & b
Step 3 − c ← a + b
Step 4 − display c
Step 5 – STOP

In design and analysis of algorithms, usually the second method is used to describe an algorithm.
It makes it easy for the analyst to analyze the algorithm ignoring all unwanted definitions. He
can observe what operations are being used and how the process is flowing.
Writing step numbers is optional. We design an algorithm to get a solution to a given problem. A
problem can be solved in more than one way.

Hence, many solution algorithms can be derived for a given problem. The next step is to analyze
those proposed solution algorithms and implement the best suitable solution.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy