Procedural language The program code is written in the form of a sequence of instructions. The user would specify what has to be done and how it can be done, i.e the step by step procedure of it. It is considered as a command-driven language. It works with the state of the machine. Its semantics are tough in comparison to other paradigms. The size of the program would be large. These steps would be executed in a sequential method. It returns restricted data types and certain allowed values only. The overall efficiency is high. The instructions are written to solve a specific/set of problems. Examples of procedural languages include BASIC, FORTRAN, ALGOL, C, COBOL, and Pascal. It is not suited for applications where time is a critical constraint. The iterative loops and recursive calls are used while working in procedural languages. Non-procedural Language The user would specify what has to be done but doesn't get into the how it has to be done part. It is known as an applicative ...
// C++ program to demonstrate // Encapsulation #include <iostream> using namespace std; class Encapsulation { private : // Data hidden from outside world int x; public : // Function to set value of // variable x void set( int a) { x = a; } // Function to return value of // variable x int get() { return x; } }; // Driver code int main() { Encapsulation obj; obj.set(5); cout << obj.get(); return 0;
Comments
Post a Comment