Difference between traditional and modern C Language

KEY DIFFERENCE

  • C is a Procedural Oriented language, whereas C++ is an Object-Oriented Programming language.
  • C supports only Pointers whereas C++ supports both pointers and references.
  • C does not allow you to use function overloading whereas C++ allows you to use function overloading.
  • C supports built-in data types whereas C++ supports built-in as well as user-defined data types.
  • C language follows the Top-Down programming approach whereas C++ follows a bottom-up programming approach.
  • C scan and printf are used for the standard input and output while in C++, cin and cout are given for standard input and output operations.‬ ‬‬‬
Main difference: C was originally developed by Dennis Ritchie at AT&T Bell Labs between 1969 and 1973. It has a free-format program source code. C is a general-purpose programming language. C is one of the oldest currently used programming languages and is one of the most widely used programming languages. ANSI C is a set of successive standards which were published by the American National Standards Institute (ANSI) for the C programming language. The ANSI specifies the syntax and semantics of programs written in C.

Some other differences between C and ANSI C:

ANSI C allows the inclusion of a function prototype which gives the type of the function and the type of each parameter before defining the function.
In C, function declarations are assumed by default to be of type int. Hence, integer type functions need not declared at all.
In C, function headers have different syntax.
Function prototypes must be declared without a list of arguments and types, and consist of the type, function name and an empty set of parentheses.
C converts all float types in an expression to double precision types.
The type signed char is not available in C, but is in ANSI C.
In C, type void is not available.
In C, functions are assumed to return integer if they return nothing.
Many old C compilers expect that the first character of a preprocessor directive line is a #. No leading white space is allowed.
In C, the signed type qualifier is not available.
In C, the unsigned qualifier can be used to qualify integer types only.
In C, the unary positive sign is not allowed.
In C, the type long double is not available.
In C, the const qualifier is not available.
In C, enumeration type is not available.
Automatic arrays cannot be initialized in declarations in C. Only external and static arrays can be initialized.
Automatic structures and arrays of structures cannot be initialized in declarations in C.
In C, Some old compilers may not allow references to entire structures, requiring the use of structure pointers or individual structure members.

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.

C Vs. C++: Key Differences

Basis of distinctionCC++
Programming typeIt is a Procedural Oriented language.It is an Object-Oriented Programming language.
ApproachC language follows Top Down programming approachC++ follow bottom-up programming approach.
File extensionThe file extension of a C program is .cThe file extension of a c+ + program language is.cpp
Program divisionIn 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.
StructureStructure 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 functionIt does not allow inline function.It supports inline function.
Standard I/O operationsIn C scan and printf are used for the standard input and outputIn C++ cin» and cout« are given for standard input and output operations.‬ ‬‬‬
Data SecurityIn 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 CodingC 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 languagesC is not compatible with another language.C++ is compatible with the other generic programming languages.
PointerC supports only Pointers.C++ supports both pointers and references.
VariableIn C, the variable should be defined at the beginning of the program.C++ allows you to declare variables anywhere in the function.
Point of FocusC 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 OverloadingC does not allow you to use function overloading.C++ allows you to use function overloading.
Data TypesC 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 HandlingC 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.
FunctionsDoes not allows functions with default arrangementsAllow functions with default arrangements.
NamespaceIt is absent in C language.It is present in the C++ language.
Source CodeFree-format program source code.Originally developed from the C programming language.
RelationshipC 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 byFunction-driven languageObject-driven language
FocusFocuses on method or process instead of data.Focuses on data instead of method or procedure.
EncapsulationDoes not support encapsulation. As Data and functions are separate and free entities.Supports encapsulation. Data and functions are encapsulated together as an object.
Information hidingC 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 managementC provide malloc() and calloc() functions for dynamic memory allocation.C++ provides a new operator for this purpose.
Data TypesSupports built-in data types.Supports built-in & user-defined data types.
Global VariablesAllows Multiple Declaration of global variables.Multiple Declaration of global variables are not allowed.
Concept of MappingThe mapping between Data and Function is very complicated.The mapping between Data and Function can be easily established using "Classes and Objects."
InheritanceInheritance is not supported CInheritance is possible in C++ language.
Default header fileC used stdio.h header file.C++ uses iosteam.h as default header file.
Virtual functionThe concept of virtual Functions are present in C.The concept of virtual Function is not used in C++.
KeywordsContain 32 keywords.Contains 52 keywords.
PolymorphismIn C. Polymorphism is not possibleThe concept of polymorphism is used in C++. Polymorphism is one of the most Important Features of OOPS.
GUI programmingC language offers GTK tool for GUI programmingC++ supports Qt tools for GUIprogramming


Post a Comment

Thanks for comment.

Previous Post Next Post