C Programming
Unit-1
Programming Paradigms
Programming paradigms are different ways or styles in which a given
program or programming language can be organized.
Each paradigm consists of certain structures, features, and opinions
about how common programming problems should be tackled.
Imperative programming consists of sets of detailed instructions that are given to
the computer to execute in a given order.
1- Pour flour in a bowl
2- Pour a couple eggs in the same bowl
3- Pour some milk in the same bowl
4- Mix the ingredients
5- Pour the mix in a mold
6- Cook for 35 minutes
7- Let chill
Procedural Programming
In procedural programming, the user is encouraged to subdivide the program
execution into functions, as a way of improving modularity and organization.
Example of procedural programming is BASIC, C, and Pascal.
function pourIngredients() {
- Pour flour in a bowl
- Pour a couple eggs in the same bowl
- Pour some milk in the same bowl
}
function mixAndTransferToMold() {
- Mix the ingredients
- Pour the mix in a mold
}
function cookAndLetChill() {
- Cook for 35 minutes
- Let chill
}
pourIngredients()
mixAndTransferToMold()
cookAndLetChill()
Object-oriented Programming
The object-oriented programming paradigm is based on the concept of object. An
object contains data in the form of fields that are known as attributes and the
procedures are known as methods.
Eg: C++,java,Python
Procedural Programming
procedure, with a list of step-by-step instructions for the computer program to
follow
The paradigm deals with procedure calls that are called routines or
functions. the functions contain a series of computational commxcands to be
carried out to achieve a certain outcome.
Parallel Processing Approach
The parallel programming paradigm breaks the problem or task into chunks that
are distributed among multiple processors. These chunks work on the same
problem, simultaneously. It reduces the total time to solve a problem. It connects
multiple processors to the memory. It is either pooled across all processors or
distributed over a network. Eg:VHDL,Verilog
Declarative Programming Paradigm
It emphasizes what the program should accomplish.
It expresses the logic of a computation without describing its control
flow.Eg:SQL
Types of Declarative Programming Paradigms
o Functional Programming
o Logical Programming
o Database Processing Approach
Functional Programming
paradigm use functions, blocks of codes, intended to behave
like mathematical functions.
Logical Programming
adopts a decisive strategy to critical thinking
The paradigm is divided into three sections:
1. A series of definitions/affirmations that characterize the problem domain
2. Statements of facts that are relevant
3. Statement of objectives or goals in the form of query
Example of logical programming is PROLOG, SQL, etc.
Database Processing Approach
In this paradigm, the program statements are characterized by data instead
of hard-coding a progression of steps.