Answer to Question #246635 in C# for Sonu

Question #246635

Explain what is meant by a Programming Paradigm and the main characteristics of Procedural, Object oriented and Event-driven paradigms and the relationships among them. Write small snippets of code as example for the above three programming paradigms using a suitable programming language(s). you also need to critically evaluate the code samples that you have given above in relation to their structure and the unique characteristics.


1
Expert's answer
2021-10-05T11:15:12-0400

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 fulfil each and every demand. They are discussed below:

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.

#include <iostream>
using namespace std;
int main()
{
    int i, fact = 1, num;
    cout << "Enter any Number: ";
    cin >> number;
    for (i = 1; i <= num; i++) {
        fact = fact * i;
    }
    cout << "Factorial of " << num << " is: " << fact << endl;
    return 0;
}

Object oriented programming – 

The program is written as a collection of classes and object which are meant for communication. The smallest and basic entity is object and all kind of computation is performed on the objects only. More emphasis is on data rather procedure. It can handle almost all kind of real life problems which are today in scenario.    

import java.io.*;
   
class GFG {
    public static void main(String[] args)
    {
        System.out.println("GfG!");
        Signup s1 = new Signup();
        s1.create(22, "riya", "riya2@gmail.com", 'F', 89002);
    }
}
   
class Signup {
    int userid;
    String name;
    String emailid;
    char sex;
    long mob;
   
    public void create(int userid, String name, 
                        String emailid, char sex, long mob)
    {
        System.out.println("Welcome to 
                 GeeksforGeeks\nLets create your account\n");
        this.userid = 132;
        this.name = "Radha";
        this.emailid = "radha.89@gmail.com";
        this.sex = 'F';
        this.mob = 900558981;
        System.out.println("your account has been created");
    }
}

Event-driven paradigms

  - Service oriented

  - Time driven

  import asyncio

  def hello_world(lp):
    print('Hello World')
    lp.stop()
   
  lp = asyncio.get_event_loop()
   
  lp.call_soon(hello_world, lp)
   
  lp.run_forever()
  lp.close()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

bek
24.03.22, 08:20

thanks

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS