Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

All About programing language C and C ++ (Besic Concept , Specification , Similarities, Difference)

 

At first we are try to know what is about  C  and C++ programming language?

·      What is C programming language?

C is middle-level programming language which was developed at Bell Lab in 1972 by Dennis Ritchie. C language combines the features of Low level as well as High-level Language. Hence its considered a middle-level Language.

C is a high-level classical type programming language that allows you to develop firmware and portable applications. The C language was developed with an objective of writing system software. It is an ideal language for developing firmware systems.

·      What is C++ programming language?

C++ is a computer programming language that contains the feature of C programming language as well as Simula67( a first object Oriented language). C++ introduced the concept of Class and Objects.

It encapsulates high and low-level language features. So, it is seen as an intermediate level language. Earlier it was called "C with classes" as it had all the properties of the C language.





Similarities between  c and  C++  are: 
 

·       Both the languages have a similar syntax.

·       Code structure of both the languages are same.

·       The compilation of both the languages is similar.

·       They share the same basic syntax. Nearly all of C’s operators and keywords are also present in C++ and do the same thing.

·       C++ has a slightly extended grammar than C, but the basic grammar is the same.

·       Basic memory model of both is very close to the hardware.

·       Same notions of stack, heap, file-scope and static variables are present in both the languages.

 

 



Difference between C and C++

 

Application Development Area

C is a good option for embedded devices and system-level code. C++, on the contrary, is a top choice for developing gaming, networking, and server-side applications. It is also a great option for the development of device drivers.

The authority of C++ lies in performance and speed. Though C also offers these both qualities, C++ takes it a step further.

Compatibility With Each Other

C is a subset of C++. Hence, C++ is a superset of C. While C++ is able to run most C code, the C compiler isn’t able to execute the C++ code.

Compatibility With Other Programming Languages

The C++ programming language provides compatibility with other generic programming languages. However, no such feature is offered by the C programming language.

Data Security, Encapsulation, and Information Hiding

As data and functions are treated as distinct entities in the C programming language, there is no support for encapsulation. The C++ code binds data and functions together in an object and, hence, supports encapsulation, which, in turn, offers information hiding.

Another major distinction between C and C++ programming languages is on the basis of data security. In the C programming language, data not as secure.

Approach

Being a procedure-oriented (structure-oriented) programming language, C follows a top-down approach. It begins with a high-level design and ends with a low-level design.

In the top-down approach, the main() function is written at first and all subfunctions are called from the main() function. Thereafter, sub-functions are written as per the requirements.

The C++ programming language is completely opposite to C in this aspect as, like all object-oriented programming languages, it follows a bottom-up approach.

Opposed to the top-down approach, the bottom-up approach starts with the low-level design and finishes with the high-level design. In the bottom-up approach, the code is developed for modules and afterward, these modules are integrated with the main() function.

Both types of approaches are involved in software development and not in program execution. In the present times, software design includes the combination of both approaches to get the best of both worlds.

C language follows Top Down programming approach

C++ follow bottom-up programming approach.

 

Default Header File

Yet another distinction that can be made between C and C++ is on the basis of the default header file used. While C uses stdio.h as the default header file, C++ makes use of the iostream.h as the default header file.

Data Types

C supports inbuilt and primitive data types. On the contrary, C++ provides support for user-defined data types in addition to primitive and built-in data types. Moreover, C++ has Boolean and String as built-in data types. No such inbuilt data types exist in the C programming language.

 

Data Security

In C language the data is not secured.

Data is secure, so it can't be accessed by external functions. (Using Encapsulation concept of OOPs)

 

Exception Handling a.k.a. Error Handling

C++ offers an easy way of exception handling by means of Try and Catch blocks. Exceptions are meant for spotting “hard” errors, which can result in incorrect code.

Unlike C++, exception handling in C needs to be managed by using other functions. This is because the programming language doesn’t provide support for exception handling.

Conventionally, a programmer coding in C needs to prevent errors from occurring beforehand. Hence, it is required to test return values from functions. In the worst case where the error is inevitable, the programmer must log the error and terminate the program gracefully.

Ease of Coding

C is described as a hands-on programming language. Hence, it is essential to tell the program everything that needs to be done. As an extension of C, C++ allows for highly controlled object-oriented code. Simply, if C is easy then C++ is easier.

Ease of Coding

C is an older programming language that is described as Hands-on. In this language, you must tell the program to do everything. Moreover, this language will let you do almost anything.

C++ is an extension language of C. It allows for the highly controlled object-oriented code.

 

File Extension

Any C program is saved with a .c extension while a typical C++ program is saved with a .cpp extension

The file extension of a C program is .c

The file extension of a c+ + program language is.cpp

 

Function Overloading

One of the powerful features brought to the table by C++ programming language is function overloading, a form of polymorphism. It enables a function with the same name to be defined for varying purposes. Overloaded functions have the same name albeit different parameters.

GUI Programming

For enabling GUI (Graphical User Interface) programming, C has the GTK tool. C++ supports Qt tools for achieving the same.

Inheritance

Inheritance is the ability of a class to derive properties as well as characteristics from some other class. As it is one of the important properties of OOPS, no such feature is available in the C programming language.

The class that inherits properties from another class is called the child class. It might also be known as derived or subclass. The class whose properties are inherited by the subclass is known as the base class. It is also referred to as the parent or superclass.

Mapping

The C programming language has a very complicated mapping between data and function. In C++, the mapping between data and function can be easily established by means of classes and objects.

 





                       C       vs       C++

Information hiding

C does not support information hiding. In this language, data are free entities and can be changed outside code.

Encapsulation hides the data. So that data structures and operators are used as per intention.

Memory management

C provide malloc() and calloc() functions for dynamic memory allocation.

C++ provides a new operator for this purpose.

Data Types

Supports built-in data types.

Supports built-in & user-defined data types.

Global Variables

Allows Multiple Declaration of global variables.

Multiple Declaration of global variables are not allowed.

Concept of Mapping

The mapping between Data and Function is very complicated.

The mapping between Data and Function can be easily established using "Classes and Objects."

Inheritance

Inheritance is not supported C

Inheritance is possible in C++ language.

Default header file

C used stdio.h header file.

C++ uses iosteam.h as default header file.

Virtual function

The concept of virtual Functions are present in C.

The concept of virtual Function is not used in C++.

Keywords

Contain 32 keywords.

Contains 52 keywords.

Polymorphism

In C. Polymorphism is not possible

The concept of polymorphism is used in C++. Polymorphism is one of the most Important Features of OOPS.

GUI programming

C language offers GTK tool for GUI programming

C++ supports Qt tools for GUIprogramming

 

Programming type

It is a Procedural Oriented language.

It is an Object-Oriented Programming language.

Approach

C language follows Top Down programming approach

C++ follow bottom-up programming approach.

File extension

The file extension of a C program is .c

The file extension of a c+ + program language is.cpp

Program division

In C programming language, a big program code is divided into small pieces which is called functions.

In C++ programming language, a big program code is divided into Objects and Classes.

Structure

Structure in C not provide the feature of function declaration.

Structure in C++ provides the feature of declaring a function as a member function of the structure.

Inline function

It does not allow inline function.

It supports inline function.

Standard I/O operations

In C scan and printf are used for the standard input and output

In C++ cin» and cout« are given for standard input and output operations.

Data Security

In C language the data is not secured.

Data is secure, so it can't be accessed by external functions. (Using Encapsulation concept of OOPs)

Ease of Coding

C is an older programming language that is described as Hands-on. In this language, you must tell the program to do everything. Moreover, this language will let you do almost anything.

C++ is an extension language of C. It allows for the highly controlled object-oriented code.

Compatibility with other languages

C is not compatible with another language.

C++ is compatible with the other generic programming languages.

Pointer

C supports only Pointers.

C++ supports both pointers and references.

Variable

In C, the variable should be defined at the beginning of the program.

C++ allows you to declare variables anywhere in the function.

Point of Focus

C focuses on the steps or procedures that are followed to solve a problem.

C++ emphasizes the objects and not the steps or procedures. It has higher abstraction level.

Function Overloading

C does not allow you to use function overloading.

C++ allows you to use function overloading.

Data Types

C language does not allows you to declare String or Boolean data types. It supports built-in and primitive data types.

C++ supports String and Boolean data types.

Exception Handling

C does not support Exception Handling. However, it can be performed using some workarounds.

C++ supports Exception handling. Moreover, this operation can be performed using try and catch block.

Functions

Does not allows functions with default arrangements

Allow functions with default arrangements.

Namespace

It is absent in C language.

It is present in the C++ language.

Source Code

Free-format program source code.

Originally developed from the C programming language.

Relationship

C is a subset of C++. It cannot run C++ code.

C++ is a superset of C. C++ can run most of C code while C cannot run C++ code.

Driven by

Function-driven language

Object-driven language

Focus

Focuses on method or process instead of data.

Focuses on data instead of method or procedure.

Encapsulation

Does not support encapsulation. As Data and functions are separate and free entities.

Supports encapsulation. Data and functions are encapsulated together as an object.



Hope you understand and its help you little bit . 
Have a good day and stay safe , for any question comment bellow.

Post a Comment

0 Comments

Ad Code

Responsive Advertisement