Posted By:
4 Jul, 2013 1:32 pm PDT

Difference between C and C++

C and C++ are both similar languages. But what is the difference between them?

 C vs C++

  1. C follows the procedural programming paradigm whereas C++ follows object oriented paradigm.
  2. In C, the data is insecure whereas the data is secure (hiding) in C++. The difference is due to specific OOP features like Data Hiding which are not present in C.
  3.  C is regarded as a low-level language (difficult interpretation & less user friendly) while C++ has features of both low-level (concentration on what's going on in the machine hardware) & high-level languages (concentration on the program itself) & hence is regarded as a middle-level language.
  4. Functions are building blocks of C whereas objects are building blocks of C++.
  5. C++ supports overloading whereas C does not. 
  6. In case of C++, functions can be used inside structures whereas structures cannot contain functions in C.
  7. C uses scanf and printf whereas C++ uses cin>> and cout<< as their respective input and output.


C vs Java

Although Java was modelled after C, it differs from C in many ways. Java does not incorporate a number of features available in C. For the benefit of C programmers, we point here a few major differences between C and Java languages.

Java is a lot like C but the major difference between Java and C is that Java is an object-oriented language and has mechanism to define classes and objects; whereas C is a procedure oriented language. In an effort to build a simple and safe language, the Java team did not include some of the C features in Java.

  1. JAVA is Object-Oriented while C is procedural. Different Paradigms, that is, most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.
  2.  Java is an Interpreted language while C is a compiled language.
  3. C is a low-level language while JAVA is a high-level language.C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up {on the rocks} approach. In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA (and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole.
  4. JAVA supports Method Overloading while C does not support overloading at all: JAVA supports function or method overloading-that is we can have two or more functions with the same name (with certain varying parameters like return types to allow the machine to differentiate between them). That is to say, we can overload methods with the same name having different method signatures. JAVA (unlike C++), does not support Operator Overloading while C does not allow overloading at all.
  5. Unlike C, JAVA does not support Preprocessors, & does not really need them. The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. Since Java does not support preprocessors; we cannot use #define,   #include, and #ifdef statements. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the #include used to include files in C.
  6. Java does not include the C unique statement keywords goto, sizeof, and typedef.
  7. Java does not contain the data types struct, union and enum.
  8. Java does not define the type modifiers keywords auto, extern, register, signed, and unsigned.
  9. Java source and binaries are entirely portable (subject to availability of appropriate libraries), since the source format is standardized, and the binaries run on a software emulation of a standardized processor, which also slows execution. In C, binaries are not usually portable from one platform to another, because they use the platform's native hardware processor directly, and so run faster.
  10. Java does not support an explicit pointer type. Pointer go backstage in JAVA while C requires explicit handling of pointers. When it comes to JAVA, we don’t need the *’s & &’s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects.
  11. Java does not support any mechanism for defining variable arguments to functions.
  12. ava requires that functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in C.
  13. Java adds new operators such as instanceof and >>>.
  14. Java adds labelled break and continue statements.
  15. The standard Input & Output Functions: Although this difference might not hold any conceptual (intuitive) significance, but it’s maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & functions.
  16. Java adds many features required for object-oriented programming.
Was it useful?  

Please login to reply to this problem.