Monolithic and Procedural Programming

887 views 7 slides May 12, 2021
Slide 1
Slide 1 of 7
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7

About This Presentation

This presentation contains:
About Monolithic and Procedural Programming and their features
Difference between Monolithic and Procedural Programming
Examples of Monolithic and Procedural Programming
Combine example of Monolithic and Procedural Programming


Slide Content

Monolithic and Procedural Programming

Monolithic Programming The Monolithic programming paradigm is the oldest. It has the following characteristics. It is also known as the imperative programming paradigm. In this programming paradigm, the whole program is written in a single block. We use the  goto  statement to jump from one statement to another statement. It uses all data as global data which leads to data insecurity. There are no flow control statements like if, switch, for, and while statements in this paradigm. An example of a Monolithic programming paradigm is Assembly language.

Procedural Programming The procedure-oriented programming paradigm is the advanced paradigm of a structure-oriented paradigm. It has the following characteristics. This paradigm introduces a modular programming concept where a larger program is divided into smaller modules. It provides the concept of code reusability. It is introduced with the concept of data types. It also provides flow control statements that provide more control to the user. It follows all the concepts of structure-oriented programming paradigm but the data is defined as global data, and also local data to the individual modules. In this paradigm, functions may transform data from one form to another. Examples of procedure-oriented programming paradigm is C, visual basic, FORTRAN, etc.

Key Features of Procedural Programming The key features of procedural programming are given below: Predefined functions: A predefined function is typically an instruction identified by a name. Usually, the predefined functions are built into higher-level  programming languages , but they are derived from the library or the registry, rather than the program. Local Variable: A local variable is a variable that is declared in the main structure of a method and is limited to the local scope it is given. The local variable can only be used in the method it is defined in, and if it were to be used outside the defined method, the code will cease to work. Global Variable: A global variable is a variable which is declared outside every other function defined in the code. Due to this, global variables can be used in all functions, unlike a local variable. Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are grouped together to conclude a larger task first. Every group of systems then would have its own tasks finished one after the other until all tasks are complete. Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions, subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by reference’.

Paradigm Description Main traits Related paradigm(s) Examples Imperative Programs as  statements  that  directly  change computed  state  ( datafields ) Direct  assignments , common  data structures ,  global variables C ,  C++ ,  Java ,  Kotlin ,  PHP ,  Python ,  Ruby ,  Wolfram Language Procedural Derived from structured programming, based on the concept of  modular programming  or the  procedure call Local variables , sequence, selection,  iteration , and  modularization Structured, imperative C ,  C++ ,  Lisp ,  PHP ,  Python ,  Wolfram Language

Examples: #include <iostream.h> //procedural programing Void fact(int num) {int fact=1; for (int i = 1; i <= num; i++) { fact = fact * i; } cout << "Factorial of " << num << " is: " << fact << endl; } void main() { int num; cout << "Enter any Number: "; cin >> num; fact(num); }

#include<iostream.h> // monolithic programing void main () {  int x = 10;  loop: cout<<x<<",";  x--;  if (x>0)    goto loop; } #include <iostream> // combine example void fact(int num) {int fact=1,i=1; bin: if( i <= num) { fact = fact * i; i ++; goto bin; } cout << "Factorial of " << num << " is: " << fact << endl; } int main() {int num; cout << "Enter any Number: "; cin >> num; fact(num); }