Prompt
Prompt
12/9/2024
Introduction of Programming Paradigms
Answer:
Introduction of Programming Paradigms:
Paradigm can also be termed as method to solve some problem or do some task. Programming
paradigm is an approach to solve problem using some programming language or also we can say
it is a method to solve a problem using tools and techniques that are available to us following
some approach. There are lots for programming language that are known but all of them need to
follow some strategy when they are implemented and this methodology/strategy is paradigms.
Apart from varieties of programming language there are lots of paradigms to fulfill each and
every demand. They are discussed below:
Advantages:
1. Very simple to implement
2. It contains loops, variables etc.
1|Page
Disadvantage:
1. Complex problem cannot be solved
2. Less efficient and less productive
3. Parallel programming is not possible
Now in Python:
2|Page
Output:
Average of five numbers: 24.2
Imperative programming is divided into three broad categories:
1. Procedural,
2. OOP
3. parallel processing.
These paradigms are as follows:
Procedural programming paradigm:
This paradigm emphasizes on procedure in terms of under lying machine model. There is
no difference in between procedural and imperative approach. It has the ability to reuse
the code and it was boon at that time when it was in use because of its reusability.
Examples of Procedural programming paradigm:
C++ language:
Advantages:
Data security
Inheritance
Code reusability
Flexible and abstraction is also present
3|Page
Examples of Object Oriented programming paradigm:
C++
Output:
Welcome to ABM Bank
Lets create your account
your account has been created
4|Page
produced. This is the only difference between imperative (how to do) and declarative (what to
do) programming paradigms. Getting into deeper we would see logic, functional and database.
Logic programming paradigms:
It can be termed as abstract model of computation. It would solve logical problems like
puzzles, series etc. In logic programming we have a knowledge base which we know
before and along with the question and knowledge base which is given to machine, it
produces result. In normal programming languages, such concept of knowledge base is
not available but while using the concept of artificial intelligence, machine learning we
have some models like Perception model which is using the same mechanism.
In logical programming the main emphasize is on knowledge base and the problem. The
execution of the program is very much like proof of mathematical statement, e.g., Prolog
predicates
sumoftwonumber(integer, integer).
clauses
sumoftwonumber(0, 0).
sumoftwonumber(N, R) :-
N > 0,
N1 is N - 1,
sumoftwonumber(N1, R1),
R is R1 + N.
Database approach:
5|Page
Database/Data driven programming approach:
This programming methodology is based on data and its movement. Program statements
are defined by data rather than hard-coding a series of steps. A database program is the
heart of a business information system and provides file creation, data entry, update,
query and reporting functions. There are several programming languages that are
developed mostly for database application. For example SQL. It is applied to streams of
structured data, for filtering, transforming, aggregating (such as computing statistics), or
calling other programs. So it has its own wide application.
CREATE DATABASE databaseAddress;
CREATE TABLE Addr (
PersonID int,
LastName varchar(200),
FirstName varchar(200),
Address varchar(200),
City varchar(200),
State varchar(200)
);
6|Page