DIFFERENCES BETWEEN C AND C++ LANGUAGE

What are the differences between the C and C++ language?

C++ is the improved version of the C language. Although they have a common syntax the two languages are very different in nature C is a procedural language Its general programming method is to break the task into smaller tasks This is known as top-down design C++ It is an object-oriented language. To solve a problem with C++ the first step is to design classes that are abstractions of physical objects. These classes contain both the state of the object, its members, and the capabilities of the object, its methods. After designing the classes, a program is written that uses these classes to solve the current task. C++ includes everything that is part of C and adds support. for object-oriented programming (OOP)

These programs are easier to write, understand and correct

In addition, C++ also contains many improvements and features that form a "C

better independent of object-oriented programming. C++ is really an extensible language because we can define new types in such a way that they act together like the predefined types that are part of the standard language. Some of the new features

They include encapsulation, inline function calls, overloading operators, inheritance, etc.

Although C++ is a superset of C, there are some differences between the two. First of all, in C when a function does not take parameters, its prototype has the word void However in C++ void is not necessary (it is optional)

Prototype in C:

Prototype in C++:

char f1(void);

char f1();

Another difference between C and C++ is that in a C++ program all functions must be in prototype form, in C prototypes are recommended, but optional. Also if a C++ function is declared to return a value, the return statement must return a value, in C it is not necessary that it be returned.

Another difference is where local variables are declared. In C, they must be declared only at the beginning of the block, while in C++ variables can be declared at any point. Although it is advisable to always do it at the beginning of the function.



WHY ARE C AND C++ LANGUAGES USED?

In today's world of computer programming there are many high-level languages to choose from, such as C, PASCAL, BASIC and Java. These are all excellent languages to satisfy most programming tasks. Still, there are several reasons why many programmers put C at the top of the list:


C is a powerful and flexible language. What you can achieve with C is limited only by your imagination. The language itself imposes no restrictions on the programmer. C is used for projects as diverse as operating systems, word processors, graphics, spreadsheets, and compilers for other languages.


C is a popular language preferred by professional programmers. As a result a wide variety of compilers and useful accessories are available for C.


C is a portable language. Portable means that a C program written for one computer system (an IBM PC, for example) can be compiled and run on another system with little or no modification. Portability is achieved by the standard for C. , the ANSI system of rules for C compilers.


C is a language of few words, containing only a handful of terms, called keywords, which serve as the basis on which the language's functionality is built. You might think that a

language with more keywords (sometimes called reserved words)

It would be more powerful. This is not true. When you program with C, you will find that it can be programmed to do any task.


C is modular. C code must be written in routines called functions. These functions can be reused in other applications or programs. By passing bits of information to functions, you can create useful, reusable code.

As these features show, C is an excellent choice for your first programming language.

C++ is an envelope of C, which means that C++ contains all of C, plus new additions for object-oriented programming. If you set out to learn C++, almost everything you learn about C will still apply to C++. You are learning not only one of today's most powerful and popular programming languages, but you are also preparing yourself for object-oriented programming. .

Another language that has gotten lots of attention is Java, as C++ is based on C. If you later decide to learn Java, you will find that almost everything you learned about C can be applied.

examples:

C language


C++ language



Comentarios

Entradas más populares de este blog

Lenguaje C

Lenguaje C++