Question

Discuss the basic differences between the various paradigms of the programming languages. In what circumstances is...

Discuss the basic differences between the various paradigms of the programming languages. In what circumstances is each one particularly strong, and in what circumstances is each one particularly feeble? Elaborate with examples and sample coding from your project and from other sources.

The languages preferred to discuss are C++, C#, Prolog and JavaScript

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)Imperative programming: good for simple programs
it is step by step programming.in this paradigm, statements are defined in a sequence in which operations are performed to achieve the desired output.it is oldest programming style.
example : addition of two integers in c++
#include<iostream>
using namespace std;
int main()
{
   int a,b,c;
   a=10,b=10;
   c=a+b;
   cout<<"Sum is "<<c;
   return 0;
}

2)Declarative programming: good for data base programming.
specifies that what is the output without mentioning the logic behind the output.
example:
select empname from employee where empsal>10000

3)Structured programming:good when there is a need to control the flow of program.
it is something like imperative programming but focuses on modular approach by the extensive use of looping blocks,subroutines,blocks,nested block to hold more control over the program.

example : handling 2D array in C++
#include<iostream>
using namespace std;
int main()
{
   int arr[2][2]={{1,2},{3,4}};
   int i,j;
   for (i=0;i<2;i++)
   {
       for(j=0;j<2;j++)
       {
      
       cout<<arr[i][j];
   }
   cout<<endl;
      
   }
  
  
   return 0;
}

4)Procedural programming:
it is the combination of structured and imperative programming.
this type of programming paradigm is based on the extensive use of procedural calls.

Example
#include<iostream>
using namespace std;
void proc1();

int main()
{
   proc1();//procedural call
  
  
  
   return 0;
}
void proc1()
{
   cout<<"this is procedural call"<<endl;
}


5)Object oriented programming:good for solving real world problems.

Object oriented pricnples are based on real life scenarios
1. Encapsulation: In object oriented paradigm, data is not allowed to move freely around the program.
data and function are encapsulated together to form a single unit cales class.

Abstraction: means to disclose only necessary detail about the object(a real world entity).

2. Inheritance: offers code reusability, a new class(child class) can be derived from an existing class(old class).

3. polymorphism:- having more than one forms.
detail is given below

Object,
class,
abstraction/encapsulation,
Polymorphism,
inheritance/genralization/specialization,
Aggregation/Composition,
Association
Object:- Any real world entity which can be represented in real world.
object can be described by its attributes.
for example :- A student is an object, because one can describe a student by the following attributes
a)Name of student
b)Date of birth
c)Course
d)contact_number
e)Roll_number
and so on.
There are three important aspects about any object
1)State
2) behavior
3)Identity
state:-a student may be in state of listening lecture,
behavior:- the behavior of student is to solve assignments
Identity:-every object should be identified uniquely.
every student is uniquely identified by his/her roll number.
class:- is a template/blueprint which is used to create object.
with the help of class one can define that what type of object will be created.
inheritance:- A new class(derived class) can be derived from the existing class(super class).
it offers code reusability
abstraction:- to disclose only necessary details about the object.
encapsulation:- function and data are wrapped together to form a single unit(class).
ultimately, unnecessary details about the object will be hidden.
polymorphism:- having more than one forms.
example:- touch screen of a mobile phone can be used to perform various tasks.
same touch screen can be used to send messages,dial phone numbers,play audio/video, and so on.
In few programming languages + operator can be used to perform mathematical addition as well as string concatenation, so + operator exhibits polymorphism.

Example: represent a student as an object in C#

using System;


namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{// create object
student student1 = new student();
student1.setname("John");
Console.WriteLine( student1.getname());
Console.ReadKey();


  
}
}
class student
{
public string name;
  
public void setname(string name)
{
this. name=name ;

}
public string getname()
{
return this.name ;
}
  
}
}

6) Functional programming: is useful when same type of task is repeated number of times.
this style of programming uses functions.
function returns a value.


Example in C++
function to return the addition of two numbers

#include<iostream>
using namespace std;

int add1(int,int);
int main()
{
  
   cout<<add1(5,5);//function calling
  
  
   return 0;
}

int add1(int a,int b)
{
   return a+b;
}

Add a comment
Know the answer?
Add Answer to:
Discuss the basic differences between the various paradigms of the programming languages. In what circumstances is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2-Many programming languages facilitate programming in more than one paradigm. TRUE OR FALSE 3-If a language...

    2-Many programming languages facilitate programming in more than one paradigm. TRUE OR FALSE 3-If a language is purposely designed to allow programming in many paradigms is called a _______________ language. What term goes in the blank? A: compiled B: interpreted C: multi-access D: multi-paradigm E: procedural 4-A "Hello, World!" program is used to do which of the following? A: Configure the compiler cache for optimizing results. B: Illustrate the basic syntax of a programming language and often is the very...

  • 1) Discuss the difference between intrinsic and extrinsic motivation. 2) What are various sources of leadership...

    1) Discuss the difference between intrinsic and extrinsic motivation. 2) What are various sources of leadership power? Explain each briefly. 3) Explain each of the following terms: -Empowerment: -Synergy - Informal groups: -Social loafing: 4) List the stages of group development and explain each briefly. 5) What is a communication barrier and what are various forms of barriers to communication? Discuss briefly. 6) What kinds of nonverbal communication are common in Turkish society? Explain with some examples that you will...

  • a. Various factors can affect blood pressure. Some of these are listed below. Discuss the differences with each of these...

    a. Various factors can affect blood pressure. Some of these are listed below. Discuss the differences with each of these factors. i) age example: BP is lower in children than in adults. ii) gender: iii) race: iv) diurnal rhythm: v) weight vi) exercise vii) emotion viii) stress b. Identify situations when a blood pressure would not be measured on a client’s arm or leg. c. State the rationale for the following nursing actions: place client’s arm at heart level, palm...

  • C programming is the main one and pick another code of choice!!! Background This assignment is...

    C programming is the main one and pick another code of choice!!! Background This assignment is based on one of the Big Ideas in this course, namely that reading C source code is a real aid in learning how to write C code. To that end, in this project, you write a program that scans C source from the 'Net and calculates some simple statistics. We're learning lots of concepts, and by running the program you write here on several...

  • For this course project, you will use various database management and programming techniques to design and...

    For this course project, you will use various database management and programming techniques to design and develop an online sales and distribution system for a fictitious organization. There are two phases—you will complete the first phase this week and the second phase in W5 Assignment 2. Rationale The focus of the project is to develop your database programming skills. This project will help you get a fair idea of the sales and distribution system in any organization that has a...

  • On Twitter (a social media platform), there is a friendly debate over what the ‘best’ programming...

    On Twitter (a social media platform), there is a friendly debate over what the ‘best’ programming language is for data analysis. Two of the dominant languages that battle back and forth for ease of use are Python and R. To get to the bottom of which of these two languages have a higher ranking for ease of use, a Twitter user created a survey that collected data from post-secondary school students who had taken one course in either Python, or,...

  • Capital Budgeting is the financial planning component of business. Companies analyze various business alternatives to discover...

    Capital Budgeting is the financial planning component of business. Companies analyze various business alternatives to discover which alternatives are profitable. In order to invest in various projects corporations need to raise capital from many sources including stocks, preferred stocks, bonds, and retained earnings (undistributed profits). Each of these sources of funds have a cost associated with them. Stock holders expect and return, bond holders expect interest payments, and stock holders expect the company to utilize internal resources in the most...

  • 1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming...

    1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...

  • Please read the case study below on the differences between equity and liabilities. Decide whether the...

    Please read the case study below on the differences between equity and liabilities. Decide whether the Class A common (ie. ordinary) shares may be disclosed as part of shareholders’ equity. Explain the application of relevant passages from AASB 132 and the Conceptual Framework to the Class A Common Shares, making specific connections between wording in in the standards and framework with the features of the shares. Using the AREA framework, do you agree or disagree with the classification of the...

  • Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are...

    Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT