0% found this document useful (0 votes)
2 views

C-- EnvironmentBasics

Procedural language is a type of programming language that follows a structured sequence of steps and procedures to complete tasks, often relying on functions and commands. It contrasts with object-oriented programming, which focuses on data and real-world modeling through objects. C++ is an example of a language that incorporates both procedural and object-oriented features, enhancing flexibility and reusability in software development.

Uploaded by

Chaya Anu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

C-- EnvironmentBasics

Procedural language is a type of programming language that follows a structured sequence of steps and procedures to complete tasks, often relying on functions and commands. It contrasts with object-oriented programming, which focuses on data and real-world modeling through objects. C++ is an example of a language that incorporates both procedural and object-oriented features, enhancing flexibility and reusability in software development.

Uploaded by

Chaya Anu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

What does Procedural Language mean?

Procedural language is a type of computer programming language that specifies a series of well-structured steps
and procedures within its programming context to compose a program. It contains a systematic order of
statements, functions and commands to complete a computational task or program.
Procedural language is also known as imperative language.

Procedural language, as the name implies, relies on predefined and well-organized procedures, functions or sub-
routines in a program’s architecture by specifying all the steps that the computer must take to reach a desired
state or output.

Procedural language segregates a program within variables, functions, statements and conditional operators.
Procedures or functions are implemented on the data and variables to perform a task. These procedures can be
called/invoked anywhere between the program hierarchy, and by other procedures as well. A program written in
procedural language contains one or more procedures.
Disadvantages of Procedural languages
Procedural languages are difficult to relate with the real world objects.
Procedural codes are very difficult to maintain, if the code grows larger.
Procedural languages does not have automatic memory management as like in Java. Hence, it makes the
programmer to concern more about the memory management of the program.
The data, which is used in procedural languages are exposed to the whole program. So, there is no security for
the data.
Object-oriented Programming Languages
Object-oriented Programming is a programming language that uses classes and objects to create models based
on the real world environment. An Object-oriented Programming application may use a collection of objects
which will pass messages when called upon to request a specific service or information. Objects are able to
pass, receive messages or process information in the form of data.

Procedure Oriented Programming Object Oriented Programming


Divided Into In POP, program is divided into small parts In OOP, program is divided into parts
calledfunctions. called objects.
Importance In POP,Importance is not given to data but In OOP, Importance is given to the data rather
to functions as well as sequence of actions to than procedures or functions because it works
be done. as a real world.
Approach POP follows Top Down approach. OOP follows Bottom Up approach.
Access POP does not have any access specifier. OOP has access specifiers named Public,
Specifiers Private, Protected, etc.
Data Moving In POP, Data can move freely from function In OOP, objects can move and communicate
to function in the system. with each other through member functions.
Expansion To add new data and function in POP is not OOP provides an easy way to add new data and
so easy. function.
Data Access In POP, Most function uses Global data for In OOP, data can not move easily from
sharing that can be accessed freely from function to function,it can be kept public or
function to function in the system. private so we can control the access of data.
Data Hiding POP does not have any proper way for OOP provides Data Hiding so provides more
hiding data so it is less secure. security.
Overloading In POP, Overloading is not possible. In OOP, overloading is possible in the form of
Function Overloading and Operator
Overloading.
Examples Example of POP are : C, VB, FORTRAN, Example of OOP are : C++, JAVA, VB.NET,
Pascal. C#.NET.
Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming (OOP)

The Origins of C++


C++ was developed by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's, and is based on the C
language. The "++" is a syntactic construct used in C (to increment a variable), and C++ is intended as an
incremental improvement of C. Most of C is a subset of C++, so that most C programs can be compiled (i.e.
converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.

C is in many ways hard to categorise. Compared to assembly language it is high-level, but it nevertheless
includes many low-level facilities to directly manipulate the computer's memory. It is therefore an excellent
language for writing efficient "systems" programs. But for other types of programs, C code can be hard to
understand, and C programs can therefore be particularly prone to certain types of error. The extra object-
oriented facilities in C++ are partly included to overcome these shortcomings.

The Programming Environment

We need several pieces of software:


An editor with which to write and modify the C++ program components or source code,
A compiler with which to convert the source code into machine instructions which can be executed by the
computer directly,
A linking program with which to link the compiled program components with each other and with a selection
of routines from existing libraries of computer code, in order to form the complete machine-executable object
program,
A debugger to help diagnose problems, either in compiling programs in the first place, or if the object program
runs but gives unintended results.

I/O Library Header Files:


There are following header files important to C++ programs:
Header File Function and Description
This file defines the cin, cout, cerr and clog objects, which correspond to the standard
<iostream> input stream, the standard output stream, the un-buffered standard error stream and the
buffered standard error stream, respectively.
This file declares services useful for performing formatted I/O with so-called
<iomanip>
parameterized stream manipulators, such as setw and setprecision.
This file declares services for user-controlled file processing. We will discuss about it in
<fstream> detail in File and Stream related chapter.

The standard output stream (cout):


The predefined object cout is an instance of ostream class. The cout object is said to be "connected to" the
standard output device, which usually is the display screen. The cout is used in conjunction with the stream
insertion operator, which is written as << which are two less than signs as shown in the following example.
#include <iostream>

using namespace std;

int main( )
{
char str[] = "Hello C++";

cout << "Value of str is : " << str << endl;


}
When the above code is compiled and executed, it produces the following result:
Value of str is : Hello C++
The C++ compiler also determines the data type of variable to be output and selects the appropriate stream
insertion operator to display the value. The << operator is overloaded to output data items of built-in types
integer, float, double, strings and pointer values.
The insertion operator << may be used more than once in a single statement as shown above and endl is used to
add a new-line at the end of the line.
The standard input stream (cin):
The predefined object cin is an instance of istream class. The cin object is said to be attached to the standard
input device, which usually is the keyboard. The cin is used in conjunction with the stream extraction operator,
which is written as >> which are two greater than signs as shown in the following example.
#include <iostream>
using namespace std;

int main( )
{
char name[50];

cout << "Please enter your name: ";


cin >> name;
cout << "Your name is: " << name << endl;

}
When the above code is compiled and executed, it will prompt you to enter a name. You enter a value and then
hit enter to see the result something as follows:
Please enter your name: cplusplus
Your name is: cplusplus
The C++ compiler also determines the data type of the entered value and selects the appropriate stream
extraction operator to extract the value and store it in the given variables.
The stream extraction operator >> may be used more than once in a single statement. To request more than one
datum you can use the following:
cin >> name >> age;
This will be equivalent to the following two statements:
cin >> name;
cin >> age;
<iostream> Advantages
Increase type safety, reduce errors, allow extensibility, and provide inheritability.
 More type-safe: With <iostream>, the type of object being I/O’d is known statically by the compiler. In
contrast, <cstdio> uses "%" fields to figure out the types dynamically.
 Less error prone: With <iostream>, there are no redundant "%" tokens that have to be consistent with
the actual objects being I/O’d. Removing redundancy removes a class of errors.
 Extensible: The C++ <iostream> mechanism allows new user-defined types to be I/O’d without
breaking existing code. Imagine the chaos if everyone was simultaneously adding new incompatible
"%" fields to printf() and scanf()?!
Features of c++
C++ introduces object-oriented programming (OOP) features to C. It offers classes, which provide the four
features commonly present in OOP (and some non-OOP) languages: abstraction, encapsulation, inheritance,
and polymorphism.
C++ features are –
1. C++ is an Object Oriented Programming Language (OOPL).
2. C++ have huge Function Library
3. C++ is highly Flexible language.
4. C++ can be used for developing System Software viz., operating systems, compilers, editors and data
bases.
5. C++ is suitable for Development of Reusable Software. , thus reduces cost of software development.

You might also like