10 Major Differences Between C And C++

344

cover-image-10-major-differences-between-c-and-c++

C++, as the name suggests, is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C…

1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented)

In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process.
Also, it is easier to implement/edit the code in case of C++ for the same reason.

2. In case of C, the data is not secured while the data is secured(hidden) in C++

This difference is due to specific OOP features like Data Hiding which are not present in C.

3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post)

C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language.

Note: This is a relative difference. See updates at end of this post.

4. C uses the top-down approach while C++ uses the bottom-up approach

In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems.

5. C is function-driven while C++ is object-driven

Functions are the building blocks of a C program while objects are building blocks of a C++ program.

6. C++ supports function overloading while C does not

Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature)

7. We can use functions inside structures in C++ but not in C.

In case of C++, functions can be used inside a structure while structures cannot contain functions in C.

8. The NAMESPACE feature in C++ is absent in case of C

C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)

9. The standard input & output functions differ in the two languages

C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions

10. C++ allows the use of reference variables while C does not

Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.

MORE –

11. C++ supports Exception Handling while C does not.

C does not support it “formally” but it can always be implemented by other methods. Though you don’t have the framework to throw & catch exceptions as in C++.

(will add more..)

UPDATES (ref to comments)-

Praveen – some of them r telling ‘C’ is a middle level language…..tell me the correct type of level language….?

Answer-@praveen – I agree there are always mixed opinions about this one. Some even like to call it a high-level language. But there’s really no determining factor behind the level of a programming language. Essentially, we’re making all the changes at the machine level, right? Now, as we increase the abstraction and move away from the machine-level, the level of the language increases. So, the level is nothing but the level of abstraction. So, most of the languages we use in applications today will have aspects of both machine-level and user-level. The two levels are machine-level & user(real world)-level while high & low levels are relative terms. Although, C is on a lower level of abstraction “relatively”- when compared to C++. Hence, referred to here as low-level.

Mitchell –
cin and cout are part of the std namespace, and they’re not functions. They’re almost like “pipes” in a sense. What you’re doing is essentially bit shifting (<> are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.

Don’t forget to check out :

Share.

About Author

Founder at Durofy. Blogs on technology & startups, runs a full service digital agency, teaches AP Calculus.

344 Comments

  1. Pingback: Top 10 Software Languages You Must Know | Connect2Compute

  2. Pingback: What to start with C / Python / Java or something else | dishantchavda

  3. Very good article. However, I would have to argue that C is not a low-level, but in fact a high-level programming language. High-level is close to what humans interpret, and low-level would be more or less machine language, such as assembly.

  4. helllo……. thanx for this information ….it has a clear differences between the c n c++ in a simple lang……

  5. Hey guyz..
    i’m a IT student n m now a dayz learning C language..
    i’ve learnt C++ first in high school.. Now, I feel C language is tougher than C++..
    this article helps me lil’.. But I need more difference in C n C++…
    can anyone show me the format of C?? How in C header files r written n how program is closed.. N is there void main in C??

    • C is easier (esp. after I learn about java, they’re twin! Without the pointer CMW). C++ much more complex with many feature addition.

  6. Hi,
    Im studenting electronic engneering(control) at tabriz university.which programming language is suittble for me?
    and how can i learn it?

  7. SHRINIVAS M.COM GULBARGA on

    hi ,friends this is shrinivas i have so much intresting inlearning linux and c++ i am studying in m.com 4 sem and especially animination is one of the my intresting topic

    =

  8. Here c is mentioned as low-level and C++ as Middle level…but both c and c++ are High level as they completely using all high level features….

    • High level or low level doesn’t related to functions. It depends on the level of abstrction, in c the level of abstraction is low as compare to cplus

  9. C++ is not a strict superset of C, ithere are some minor differences i.e. code that will compile in c but won’t compile in c++ such as void pointer casts. Function overloading is supported by C. 2 variables can point to the same memory location, ever heard of pointers? Talk of ‘level’ of languages is unjustified and there is no ‘mixed opinion’, there are high and low level languages i.e machine code/assembly (low) and 3rd generation onwards (high level). The word for “data hiding” you’re looking for is “encapsulation” and is part of the OOP paradigm and you already explained the paradigm difference, so it is a moot point. Please learn what you’re talking about before posting an article. .

  10. I prefer c is simple compared to c++ e.g.
    C:

    Main ()

    {

    Printf(“hello world”)

    }

    But c is a longer process

  11. srinivasa rao chevala on

    C lamgauge is supporting the functional overloading. in a single program u r using no of printf and scanf functions, those are taking different values

  12. You’re not shifting bits into and from std::cout and std::cin. ‘<>’ are overloaded, they aren’t shifting operators in the case of ::cout and std::cin. Please fix that.

  13. Hi friends,

    I am working as a trainer in networking and system administration and I am so much interested in learning Linux in deep, especially Linux Kernel. Can anyone tell which language Linux kernel is written? Someone is saying it is Assembly Level coding and some other are saying it is pure C programming language. If I have a good understanding of C Language, can I able to understand the Linux Kernel coding? (Of-course with the help of some Linux guru or by reading comments) ?

    Thanks a lot for this great site.

    Toms.

  14. According to Yashwant Kanetkar C is a middle level language but above according to the Point 3-C is low level language I think this is wrong not correct mostly we consider low level language is Machine language not C

  15. rahul_bhadauria on

    thats good from technical side but not good from layman side
    overall its good
    plz make it more simpler by utting some code examples

    • low: machine level;
      middle: supports both low and high level
      high: can interpret the meaning like ordinary language

    • Low level is Machine Language and Middle level language is C language in which some feature contributes of low level language

  16. Heeey woww it was easy to understand coz it not only has the difference but
    also the meaning for it.. wowwwww realli useful info :) thank you soo much.. :)

  17. sir! tell me what is the difference of java to many other languages…..
    and now I am feeling good because I got my ans……………

  18. radhika bhagchandani on

    thanx a lot….. thanx a tonnes actually… tomorrow i hav an interview and was needing dis differnce urgenty:))))))

  19. Really,it’s so good to read.In c global variables are changing why?,what is the use of static and constant in c&c++?.difference between arguments&parameters?

  20. Thanks for giving basic differences b/w c and c++..I need to know why pointers concept is not supported in c++???

  21. Pingback: Blue Ray Plus - Latest Technology News

  22. 1 point i want to tell that
    in C we use #include as inclusion file but
    in C++ we use #include as inclusion file.

  23. Rishabh….u did a great job.i loved it……very helpful to me…..Thanx dude…..keep it up.

  24. mr.Rishabh Dev ,do u know how useful it is for us! thanks dev,by giving the explanation for each point can makes me easily understand.

  25. prathamesh :

    hey rishabh i m not able to handle the pointers and all the pointers stuff so can u tell me wer shuld i refer for the basics of pointers ????????

    & also tell me which book is best to refer for c& c++ programming w8ng for your reply …

    Hello! You can start with this post on the basics of pointers : http://www.durofy.com/programming/an-introduction-to-pointers-in-c-programming/
    Refer to a good programming book to learn the basics. I recommend “The C Programming Language” by Brian Kernighan & Dennis Ritchie to clear your basics. Once you are good in C, then move to C++.

  26. hey rishabh i m not able to handle the pointers and all the pointers stuff so can u tell me wer shuld i refer for the basics of pointers ????????

    & also tell me which book is best to refer for c& c++ programming w8ng for your reply …

  27. Limitation of C

    (1) Inability to express large program as an abstraction
    (2) Unsuited for very large scale programming
    (3) No Mechanism for information reuse with little modification [Team Contribution & Correction due to error is difficult]
    (4) Can only identify Errors & cannot handle Exceptions
    (5) C++ is Multi-paradigm language
    (6) Features like Data Hiding, Polymorphism, Inheritance are not available

  28. thank u so much 4 giving these much points to clarify ourself its very very useful for us……………thanks……………………..

  29. tis infrmation is useful for all,thanks for providing tis information to all..

  30. You can use multiple variables(pointers) to point into a single memory location in C. You use it especially when implementing linked lists.

  31. Hey Rishabh,
    I am new to C/C++ environment. Can you tell me the difference between the C/C++ IDEs/Compilers also what if I use C++ to compile code for C and vice versa? What difference will it make ?

  32. jinendra khane on

    thanx…4 providing.bt there r again many diffrances remains like in c++ default main is int type while in c its void.

  33. hey i need to convert a C code to C++ or JAVA
    could somebody help??
    i can post the code.

  34. Mitchell :
    You can use functions inside of structs in C via pointers, but I supposed that’s not what you really mean, it just sounds slightly misleading to me.
    Also, cin and cout are part of the std namespace, and they’re not functions. They’re almost like “pipes” in a sense. What you’re doing is essentially bit shifting (<> are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.
    All in all a good article, just a couple nitpicks.

    You are not bit shifting. Bit shifting changes values it does not move variables.

    The operators are overloaded and called “insertion operators” in the iostream context. I’m not sure if you just wanted to seem smart or simply have a poor mental model but you are wrong and now everybody who read your addendum is also misinformed.
    http://www.cplusplus.com/reference/iostream/ostream/operator<</

  35. hiii can you please tell me the difference between while and for loop.why we use this both when they are peforming the same task and also where to use while and where to use for loop

  36. shivani can you tell me what is the difference between if,if else,nested if,and else if ladder statement………..

  37. In 7., what does “functions insides structures” actually mean? I mean, I can use function pointers inside of structs perfectly fine. Do you mean functions that can access the structs data automatically?

    I also don’t get 10.
    When I do

    int a = 4;
    int *b = &a;

    isn’t this what you described as “using the same memory by different names”?

  38. Nicely written…..
    really useful !!!!!!! i’l use in my assignment , preparing today…… :)

  39. What are the things are not possible in c when cOmpaRed to c. Pls tell me..
    Why the c++ is better than c??

  40. Hehhh can yu please provide me the complete information with explanation on the main OOPS principles..please ya
    And the above information is perfct..thank yu ya..

  41. Thanx……boss.. this difference is very easy to store on my mind, its never forget to me.. short answers nice keep it up boss… and also keep this typ of answers always it will help full for students..like me

  42. Thanks. for special points , I am very satisfied by these 10 points and these are very help full for me

  43. vinny aggarwal on

    what is the differnce between c++ and other structured languages?
    plz
    do reply…

    thank you!

  44. shuhaibvalapuram on

    12.Main doesn’t Provide return 0 Automatically in c,but in c++ it is..
    13.No Boolean type in C,but it is present in c++
    14.We must declare functions before use in c++,but c does’t require it.
    15.presence of keyword ‘new’ instead malloc in c

  45. Alex D :

    Wait so can I learn C first and then move on to C++… will that work? Because I have started watching video tutorials about C and I am learning a lot but will I be able to do those things in C++?
    Please reply!
    Thanks

    That’s the only way it works. I hate to call C a “programming language”. It is more like a “programming prerequisite”. C is to programming what Algebra is to Calculus.

  46. Wait so can I learn C first and then move on to C++… will that work? Because I have started watching video tutorials about C and I am learning a lot but will I be able to do those things in C++?
    Please reply!
    Thanks

  47. You can use functions inside of structs in C via pointers, but I supposed that’s not what you really mean, it just sounds slightly misleading to me.

    Also, cin and cout are part of the std namespace, and they’re not functions. They’re almost like “pipes” in a sense. What you’re doing is essentially bit shifting (<> are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.

    All in all a good article, just a couple nitpicks.

  48. C is not a client server model while C++ is a client server model. C++ can solve the real world problems while C can’t. These are also the differences.

  49. Pingback: Advantage of C over C++ ..!

  50. can u send some programs such as, factorial,prime no,fibonaci
    and can u shortly explain about pointer?

  51. Point number 3 is totally wrong bcz c is middle level language and c++ is high level language.
    so plz correct it.

  52. anita s karamudi on

    good points i got and one more suggestion is….

    c support 32 key words and c++ support 42 key words

  53. SANKALP SANGLE on

    can u tell me which was the first version/compiler of c++….urgent!!!!!!!!!!!!!!!!!!!!!

  54. Nitin Sharma on

    My village is Himayoupur (G.B.Nagar). But at this time i am living in ghaziabad finally i will say notes are very helpful for self study and extra knowledge about everything.So for this facility i will thanks to internet service provider and notes provider.

  55. Nitin Sharma on

    Notes are very helpful for self study and extra knowledge.I will thanks to giver and internet.

  56. CHANDAN RANCHI on

    he, thanks 4 helping us…..we would b ever thankful 2 u. once again …..THANKS

  57. Very good my friend…
    There is one more difference that C don’t have ++ like C++….
    Joking man

  58. please send us a code to show how c is top down and c++ is bottom up approach v’l b waitin

  59. Just thought of another. Actually, this is a side-effect of not having classes, but dynamic allocation in C uses only malloc() and free(), since there is no concept of a constructor or destructor.

  60. Not a complete list. A couple of other differences:

    C allows void* to be assigned to another type with no warnings.
    C requires the struct keyword when defining a variable of a struct type. C++ automatically “typedefs” structs.
    C has no operator overloading.
    You can omit the return in main() in C.

    There are some others, but it’s been a while since I used C.

  61. its really a very gud differences… it will help the students a lot.. so thanx a lot for helping students….:-)

  62. Thanks a lot Sir!!!
    Its really a very basic thing in software empire.
    One can not point out such smaller but major differences.
    You gave us it as ready made.
    Thanks a lot once again!!!

    • @praveen – I agree there are always mixed opinions about this one. Some even like to call it a high-level language. But there’s really no determining factor behind the level of a programming language. Essentially, we’re making all the changes at the machine level, right? Now, as we increase the abstraction and move away from the machine-level, the level of the language increases. So, the level is nothing but the level of abstraction. So, most of the languages we use in applications today will have aspects of both machine-level and user-level. The two levels are machine-level & user(real world)-level while high & low levels are relative terms. Although, C is on a lower level of abstraction “relatively”- when compared to C++. Hence, referred to here as low-level.

  63. thank you ….dis is really very helpful ,as all the differences have been explained with clarity,and covers all the important aspect………

  64. Thanks for your cooperation for providing me such a great help coz 2morrow is my exam n i need it n i got it……….
    Thanking you.

  65. Really Awesome … Thanks a lot boss u made my engineering worth …At last i came to know the basic difference between these two………………………thanks

  66. thankyou for helping me like this, because of you i have learnt the difference between c and c++.

  67. Pingback: Durofy » 10 Major Differences Between C And JAVA

  68. Pingback: techigg.com

  69. Pingback: C++ Tutorial