C-- EnvironmentBasics
C-- EnvironmentBasics
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.
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.
int main( )
{
char str[] = "Hello C++";
int main( )
{
char name[50];
}
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.