Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

During an interview, I was asked whether I knew the difference between C and C++.

I was wondering why such question being asked?

share|improve this question
9  
Given the number of C questions I've seen in just the last few weeks tagged C++ I'd say it was a pretty important question. –  Steven Burnap Jun 10 '12 at 20:15
12  
Judging by how often I see "C/C++", I'd say it's very common. –  user16764 Jun 10 '12 at 20:15
6  
What did you answer? –  Dima Jun 11 '12 at 3:42
8  
It's common for an applicant for programming job not to know anything at all. But I wouldn't call that person a programmer. –  vartec Jun 11 '12 at 9:33
6  
@Tjaart - You do understand there are systems where a byte isn't 8 bits right? –  Ramhound Jun 11 '12 at 12:36
show 14 more comments

closed as not constructive by Jarrod Roberson, Walter, Glenn Nelson, gnat, Yannis Rizos Jun 15 '12 at 1:03

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

9 Answers

up vote 23 down vote accepted

If the questions was phrased like "Do you know the difference between C and C++?" and you were allowed to just respond with "Yes" then I could see your confusion, but if they were actually asking "What -are- the differences between C and C++?" and a more open-ended answer was expected, I can see it as a legitimate "avenue of inquiry" as they say.

For example, only having ever coded in C and never in C++, I would barely be able to answer beyond a vague "C++ supports object oriented coding?".

share|improve this answer
add comment

Some people have observed that there's a huge amount of programming job applicants who can't write code at all. So, yes, asking "obvious" questions makes perfect sense.

share|improve this answer
7  
This was going to pretty much be my answer. Having interviewed people for programming positions, I can tell you asking the obvious questions will cut out a good number of candidates very easily. –  Tyanna Jun 10 '12 at 22:56
    
A million upvotes for you. I'm alawys amazed at the beginner level questions so many interviewees cannot answer. –  HLGEM Jun 12 '12 at 17:10
1  
Then again, I've been programming for over 25 years and there are some beginner-level questions I can't really answer anymore (gets worse if you ask for definitions). I was looking at the article linked in this answer and I was like "hmmm yeah let me think about that for a minute", whereas at work I work on implementing rather complex systems and generally don't have much trouble coming up with solutions. Some of those little questions scare me more than a multi-tiered system and throwing in some multithreaded functionality, crap like that... Weird, I know. –  MetalMikester Jun 12 '12 at 17:39
    
indeed. As discussed on another P.SE thread, for interviews I've gotten into the habit of starting with ridiculously obvious questions ("how do you declare a variable in JS?", "how many bytes for 1 int in Java?", "what's a pointer?" etc...). I don't mind a first error (stress is a factor, even if I start interviews with conversations to relax them), but usually if I can get 3 strikes before reaching decent questions, then I consider it perfectly acceptable to hang up without going further or kick them out. The 5 minutes it takes to ask the stupid questions is worth the time saved. –  haylem Jun 13 '12 at 4:14
3  
In fact, I even apologize before asking these first questions, as I don't want skilled applicants to be weirded out by them, or think I'm not taking them seriously and to feel like they wouldn't belong here. –  haylem Jun 13 '12 at 4:16
add comment

There's a whole bunch of them. There's an infinity of people who have idiot lecturers who teach C-strings and new and delete, or out-of-date tutorials or bad books, who learn "C++" but actually C, who think the two are pretty close.

Of course, if you're an employer, then saying that they're the same or even similar is a big warning light.

share|improve this answer
2  
This brings up a very good point. It is acceptable and perhaps even common to teach C but use the C++ compiler. This of course leads to confusions by students who never learn the major differences betwen C and C++. I am only talking about the major differences between the same revision. –  Ramhound Jun 11 '12 at 12:39
4  
@Ramhound: It's not acceptable at all. The fact that it's common is orthogonal. –  DeadMG Jun 11 '12 at 20:13
1  
The sad fact is that C and C++ are almost universally taught badly. Go to SO and look through the C and C++ tags, and you'll see the same misconceptions, the same wrong interpretations, the same bad practices repeated over and over and over. These aren't people randomly making the same mistakes; they were taught how to make these mistakes. "My professor said..." is almost universally a red flag to me now. –  John Bode Jun 13 '12 at 20:01
add comment

There are also a small percentage of people (such as myself) who learned C++ before they learned C.

I'm sure you know the differences, but if you are a student who has only had a C++ class, and not a C class the parts of C++ that are not C compatible will not be obvious.

Some of the more obvious differences I've learned (not an exhaustive list) () struct data types originally could not contain functions, and can't have private members, meaning it is very difficult to Enforce the validity rules of an abstract data type in C. () classes are not supported in C () passing by reference using the ampersand operator is specific to C++ () C doesn't support streams or templates (*) malloc and free are intended for use only in C and not in C++

share|improve this answer
2  
I think this is a key insight... in the old days, you had a C compiler, then along came C++, so you learned the differences. Now you have C/C++ compilers and if you are taught C++ explicitly, it is well neigh impossible to know what is C and what is C++ beyond "the Object Oriented stuff" Also, I'm not sure C/C++ is the most common language to learn in anger(?) –  Al Biglan Jun 12 '12 at 18:56
1  
I'd very much hope the percentage is not as small, because those "converted to C++" C programmers often are very bad C++ programmers. –  sbi Jun 13 '12 at 9:52
add comment

Unfortunately, I think it is becoming more and more common.

I think that young programmers freshly out of technical school (or where they learn their skills from) simply do not learn older languages such as C, C++, Lisp, OCaml, etc. They simply come out as "c# programmers" or "java programmers", etc. And when they find a job, they do not challenge themselves with learning other languages.

Of course there are some that do, but from those I have worked with, there is a general tendency for the younger programmers to follow this pattern.

Disclaimer: Since I am talking about education, then there can of course be differences from country to country about what is being emphasized in the education.

share|improve this answer
    
What universities are you talking about? "Arcane" languages? I had to learn assembly for MIPS at the university of Rome... –  Vitalij Zadneprovskij Jun 11 '12 at 7:23
    
Generally, the "young" programmers I have met have had a degree in engineering. Come to think of it, almost all the programmers I work with have a degree in engineering, including myself. –  Pete Jun 11 '12 at 7:49
1  
C and C++ are still taught in school. The problem is most of the time the same compiler is used to teach both. This means they never actually learn the differences between the two languages. –  Ramhound Jun 11 '12 at 12:40
    
@Pete If I came out as a 'C# programmer' I can't imagine going to learn C or C++ as 'another language'. Surely I'd like Ruby, Haskell, Javascript, Python. C-family languages are close enough that knowing one is enough. –  Kirk Broadhurst Jun 12 '12 at 23:20
add comment

Probably not literally, in that they think C++ and C are one and the same, but in terms of truly understanding and being able to use the different features of C++, yes.

The main cause is the binary nature of listing languages / tools on your resume/CV. Essentially, the standard seems to be that if you got "Hello World" to compile and run in a language, than it is OK to list it on your resume/CV.

As it happens, the C version of "Hello, World!" also compiles and runs in C++. So, absent any other information, all that seeing "C++" on a resume tells me is that this person knows enough C to get "Hello, World!" running, and knows that most C programs will compile in C++.

Given that, I'm going to need to probe that a little bit on the interview. I probably wouldn't do so by asking a "Yes/No" "Do you know the difference?" question, in short because it has an obvious "right" answer. I would probably ask the candidate which language she liked better, why, and if there were any advantages to the one she didn't pick.

share|improve this answer
add comment

Answer

Yes, its common. I have seen this situation, either myself, coworkers, or third party libraries code.

Myself, for example, sometimes work with other programming languages or programming frameworks, and have to link, or update, to either "pure c" or "c++" libraries.

I just had the problem of modifying some "Pure C" code. And using "new" & "delete" memory allocation functions, that are "c++". The rest of the code was not object oriented

The compiler was C++. Later, I sued another compiler, and discovered the error.

Bonus

If some one ask, verbally, or in a written test, or web online test:

"Do you know the difference between C or C++"

And you answer "Yes" or "No".

They really mean:

"Do you know the difference between C or C++, if you do please tell me ?"

So, you have to answer:

"Yes. The difference its that C++ its Object Oriented, although, you may use Pure C, inside a C++ program, for backward compatibility."

Sometimes, they will not ask you "if you do please tell me", and they will assume that you don't know. Don't just answer "yes", or "no".

share|improve this answer
1  
Well, I don't think that answer is entirely right. The right answer is that C++ has robust support for Object Oriented code. It does not require it. (Which is the source of this confusion in the first place.) –  Steven Burnap Jun 12 '12 at 19:38
    
Also "you may use Pure C inside a C++ program" could mean something like "C++ is a superset of C, i.e. any C valid program is also a valid C++ program" (wrong). Or it might mean "you can link C++ programs to C libraries" (true, but most languages can link to C libraries some way or another.) You should be much more precise in an actual interview. –  nikie Jun 12 '12 at 21:34
add comment

Edit

As a foreward, note that this answer is not meant to declare that there are no differences or that I profess to know the differences, or even that I know than "Hello World" in either C or C++. It is an answer to the question by framing the terms of reference, pointing out that plenty of people know the elementary differences (e.g. one has some + characters in its name) and very few people will know all or even most of the differences.


It depends what you mean by 'programmer' and what you mean by 'difference'.

I'm a 'programmer' (although I call myself a developer) and I'd struggle to give any real differences between C and C++. If pressed I'd probably say that C++ is a superset of C that has namespaces and inheritence; different ways of dealing with memory. I know enough to patch some bugs or make some changes in your existing program but I can't imagine writing anything more than a simple utility in C or C++. I know enough to get by, but I don't paint myself as "knowing" either of those languages.

I know other 'programmers' (also developers) who wouldn't even tell you the difference between Java and FORTRAN, or Javascript and Pascal. They are good at what they do and they don't do procedural languages.

Then there are millions of mediocre programmers who barely know the single language they work with every day.

The term 'difference' is ambigious. I've pointed out what I see as some differences above, but I know they aren't definitive and complete. Very few people are going to know every difference - a lot more people are going to be able to give some vague answers (as I have) about object orientation.

share|improve this answer
5  
"I'd struggle to give any real differences between C and C++." You're certainly not a C++ programmer. Please? –  sbi Jun 13 '12 at 9:53
2  
C and C++ are vastly different languages, coded in vastly different ways. You clearly just don't know them. –  DeadMG Jun 13 '12 at 10:09
    
@sbi "I don't paint myself as "knowing" either of those languages." I'll let you decide that for yourself. –  Kirk Broadhurst Jun 13 '12 at 22:56
    
Any feedback on the downvotes? Is it because I don't know the difference between the two? I wouldn't assume that would disqualify me from answering the question. –  Kirk Broadhurst Jun 13 '12 at 23:04
1  
@KirkBroadhurst: I think I indicated what part of your answer I disliked enough to downvote, and that comment was upvoted five times as often as you were downvoted after that, so I'm not sure what explanation you're after. However, to elaborate: The term "difference" is sufficient here, since C and C++ share only superficial syntactical similarities, and, other than that, are very different languages. As for qualifications: I don't think there's a qualification needed to answer here, but when an answer is blatantly wrong as this one, it will be downvoted irrelevant of the qualification. –  sbi Jun 14 '12 at 8:53
show 2 more comments

Is it common for a programmer not to know the difference between C and C++?

Twenty years ago? Yes.

Today? Not so much.

The reason for this is because the programming landscape has changed in a big way. Many of today's programs are web-based; even programs written for desktops may be written in a higher-level language than C or C++. As such, unless you're a programmer who writes OS code, you may not know much about either of the two languages.

An interviewer may ask this question in an interview to gauge how much you know about programming fundamentals; if you know the difference between C and C++, then you likely know what object-oriented programming is, you probably understand libraries and compilers, you understand memory functions, references, pointers....many things that have influenced the programming languages of today. I don't use C++ much (and I can't really say that I'm an excellent programmer in any language; wisdom will come with time) but I can say that my experience with C++ has definitely made me a better programmer.

share|improve this answer
7  
Would have said the other way around. I see more confused people now than even 5 to 10 years ago. –  haylem Jun 13 '12 at 4:17
    
@Haylem Looking back, I think I meant to say the other way around....whoops. –  lunchmeat317 Feb 27 '13 at 2:11
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.