Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Explain procedure-oriented programming with examples.


Procedure Oriented Programming (POP) is a programming paradigm that is organized around procedures or routines. So, programs are organized as sequences of procedures or functions which carry out particular tasks. These procedures are also called subroutines, routines or functions.

On the other hand, object-oriented programming (OOP) focuses on objects and classes.

Key characterstics of procedure-oriented programming:

1. Procedures/Functions: In POP, programs are divided into procedures or functions which are blocks of code responsible for doing one thing. Typically, each procedure takes input, processes it and returns an output.

2. Top-Down Design: In POP, you start from the top level and go down to the bottom level. This means that you have to divide the main problem into smaller sub-problems and further divide each sub-problem into even smaller tasks until they can be readily solved.

3. Data is Separate from Procedures: Data and procedures are two separate entities in POP. For instance, data might be global and any procedure can access it while procedures use this data to achieve whatever they need as an output.

Example in procedure-oriented programming language like C:

#include <stdio.h>

// Procedure to calculate the sum of two numbers
int add(int a, int b) {
    return a + b;

// Main program
int main() {
    int num1 = 10, num2 = 5;
    // Calling the add procedure
    int sum = add(num1, num2);
    printf("Sum: %d\n", sum);

    return 0;