C AS A PROCEDURE ORIENTED PROGRAMMING LANGUAGE

Another step into the wide world of C. In the first tutorial, Beginning with C Programming Language, you must’ve stumbled upon the fact that C is a procedural programming language. In this tutorial, we discover more about the procedural aspect of C. Before we talk about procedural programming it is important for us to learn about programming paradigms .

PROGRAMMING PARADIGMS

Programming paradigms refer to the style of writing the program depending on the programmers choice on how he chooses to place the different elements of programming in a sensible code. Most programming language fall under only one programming paradigm but there are a few languages that can have multiple paradigms like C which is both procedural and functional programming language. Here are a few common programming paradigms:

  • Procedural Programming: It is based on procedures and allows stepwise sequential execution(explained in detail below). Eg: C, Go, Fortran, Pascal, Ada, and BASIC
  • Functional Programming: It is mostly used for mathematical functions where it takes an argument and returns a value. Eg: Common Lisp, Scheme, Clojure, Wolfram Language, F#, etc.
  • Object Oriented Programming: It is a programming language that makes use of objects which is a bundle of both data and methods. Eg: JAVA, C#, C++, VB.NET, etc.
  • Logical programming : As the name suggests logical programming is based on logic, problem domains, relations and facts. Eg: Prolog, Datalog, ASP.

PROCEDURAL PROGRAMMING

Procedural programming stems from Structured programming and is based on the concept of Procedure call. It is a programming paradigm which makes use of procedures(also called routines, subroutines or functions).Most of the Programming languages in the early days were Procedural. Procedural Programming is also known as Imperative Programming. It has well-structured computational steps  which make use of features like modularity and scoping to enhance its readability and decrease its complexity.

Modularity refers to the systematic division of a complex code into small modules. It reduces the complexity of a program and makes it easier to find and edit any part of the code if required.

Scoping refers to enclosing the variables, constants and other statements and functions in a module. Scoping and modularity are closely related as scoping is used to implement modularity.

A program gets divided into small modules for which the variables have a scope and cannot/can be accessed by other functions according to the programmers choice.

Let’s have a look at a simple procedure of finding the maximum number from two user input numbers (flow chart).

max number flowchart

Here we see a simple program in the form of a flow chart. Although this processes can be done using other programming paradigms here we focus on Procedural paradigm. In the flow chart, we see sequential steps which shows the actual flow of execution(based on decisions) that will be followed to execute the program. It goes sequentially by taking two numbers as input in the first step, comparing them in the second and resulting in the output in the third step. Thus, we get a picture of how Procedural programming works.


Although most programming paradigms are similar in many aspects, it has certain differences which distinguishes one from the other. Let’s look at the comparison of Procedural Programming with  a couple of other Programming Paradigms:

Procedural Programming vs Object Oriented Programming

  • In procedural programming the data and function are treated as different elements of a program whereas, in OOP, both are wrapped into the same bundle known as an object.
  • In Procedural programming most of the data and variable have a global access because there are no access specifiers in Procedural Programming. On the other hand, OOP offers access specifiers which can restrict the usage of the data and variables to a particular method(Eg: public, private, protected,etc).
  • Procedural programming has a Top-down approach to programming whereas, OOP has the Bottom-up approach to programming.

These are basic differences between procedural programming and Object oriented programming.

Procedural Programming vs Functional Programming

  • Procedural programming follows a series of steps for the execution of the code, whereas, functional programming can randomly go to a step depending on the function it needs to perform.
  • Functional programming makes use of sub-routine calls or tail calls and higher order functions instead of imperative loops used by procedural programming.
  • In Functional programming, programming is done by expressions and declarations rather than statements as used by procedural programming.

These are basic differences between procedural programming and Functional programming.

So that’s all for this tutorial. Hope this helps and you like the tutorial. Do ask for any queries in the comment box and provide your valuable feedback. Do come back for more because learning paves way for a better understanding.

Keep Coding!! Happy Coding!! :)