Thread: Frequent Job Interviewing Questions

  1. #1
    UCF Mystic_Skies's Avatar
    Join Date
    Oct 2004
    Posts
    33

    Frequent Job Interviewing Questions

    Hello,

    I went on a job interview not too long ago for a software engineering internship and they had asked me some questions I thought were interesting. I was just looking around online and found these resources if anyone is interested. It didn't seem like this topic had much information on the cboards so I figured I'd throw it in. Might be nice to check out if anyone has an interview coming up...

    http://www.oneparticularharbor.net/sam/interview.html

    http://www.onesmartclick.com/intervi...ogramming.html

    http://www.techinterviews.com/index.php?p=15

    http://www.scheib.net/work/questions/

    http://www.allapplabs.com/interview_..._questions.htm

  2. #2
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    Seems like getting a programming job isn't as easy as i thought.

    Here are some interesting question i found in those links , hopefully someone kind enough will answer them :

    - Difference between "C structure" and "C++ structure".

    - Can we generate a C++ source code from the binary file?

    - Is there something that I can do in C and not in C++?

    - Why preincrement operator is faster than postincrement?

    - What will happen if I allocate memory using "new" and free it using "free" or allocate
    sing "calloc" and free it using "delete"?

    - What are the techniques you use for debugging?

    - How to reduce a final size of executable?

    - Give 2 examples of a code optimization

    - What are the advantages/disadvantages of using #define?

    - What are the advantages/disadvantages of using inline and const?

    - What is the difference between a pointer and a reference?
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  3. #3
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    these are handy, and in some ways a little scarey! Some answers for the trickier questions would be nice as well

    Edit : Seems Brain Cell had similar thoughts to me, glad I'm not the only one!
    Couldn't think of anything interesting, cool or funny - sorry.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    - Difference between "C structure" and "C++ structure".
    A C++ structure can contain member functions as its just a class that defaults to public.
    - Can we generate a C++ source code from the binary file?
    Yes and no. You can disassemble a binary file and then try to convert it to C++. However with optimization it most likely will not look anything like your orginal code. Also variable names will be lost.
    - Is there something that I can do in C and not in C++?
    Variable Length Arrays (VLA)
    - Why preincrement operator is faster than postincrement?
    Because it doesn't have to store the previous value. However in reality this is usally a minute problem that the compiler can take care of.
    - What are the techniques you use for debugging?
    Debugger, assert, output variable values thoughout the code, etc
    - How to reduce a final size of executable?
    Turn off debugging symbols

    I'll answer more if I have time and no one else does

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Careful Thantos, we wouldn't want the latest workshy to get a free shot.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    I never knew about these things , thanks Thantos. Interesting stuff !!

    Here are the questions left :

    - What will happen if I allocate memory using "new" and free it using "free" or allocate using "calloc" and free it using "delete"?

    - Give 2 examples of a code optimization

    - What are the advantages/disadvantages of using #define?

    - What are the advantages/disadvantages of using inline and const?

    - What is the difference between a pointer and a reference?



    don't worry Salem , even if that kind of people get answers and pass the job interview , they would still screw up in their job.
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  7. #7
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    1.What will happen if I allocate memory using "new" and free it using "free" or allocate using "calloc" and free it using "delete"?

    If you allocate using new and free using delete everything should be ok. If you allocate with calloc and delete with delete everything will not be ok. C style memory allocation and C++ style allocation are not interchangable because it is not certain if your delete will internaly use free() or if your new uses calloc/malloc.

    2.What is the difference between a pointer and a reference?
    A pointer just points to the memory location of a said variable. A reference is the actual variable itself.
    Last edited by prog-bman; 02-23-2005 at 11:32 AM.
    Woop?

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    Also, as far as I know, references cannot be reassigned.

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    >> - What will happen if I allocate memory using "new" and free it using "free" or allocate using "calloc" and free it using "delete"?
    [16.2] Can I free() pointers allocated with new? Can I delete pointers allocated with malloc()?

    >> - What is the difference between a pointer and a reference?
    [8.1] What is a reference?

    - What are the advantages/disadvantages of using #define?
    http://www.daniweb.com/techtalkforum...html#post91131
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  10. #10
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    True Salem

  11. #11
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Ive never used variable lenght arrays in C, well Ive googled and I found this http://www.cray.com/craydoc/manuals/...34830malz.html
    is it a decent reference? And why cant the C++ Class Vector be considered a variable lenght array? by the way I didnt find variable lenght arrays in K&R is it a "new" feature? Can you name 1 book that has accurate information about it? Thanks in advance. Well Ive google a bit and found that variable lenght arrays are present in Cray C can it be considered as a part of C? I mean if I was beeing interviewed I would expect them to talk about the ANSI or at least point me the fact they might ask me for specific implementations of the language.
    Last edited by Maragato; 02-23-2005 at 01:09 PM. Reason: Ive googled

  12. #12
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    A good programmer should have a basic idea about the answer to all of these, but ultimately I think that questions like that on interviews suck - I'd much rather get a description of a function and I have to code it (Microsoft does it that way). If I need a specific answer I could always look it up in the many reference books I have - no one should be expected to know the answer to each of those questions. How will it help if I memorize the reference book but can't use logic, and therefore can't solve problems, and therfore can't code worth dingy?
    Last edited by axon; 02-23-2005 at 02:10 PM.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  13. #13
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    I will actually give you an example of the above: I have a friend who studies his butt off, mainly memorization and such, gets good grades on exams and passes classes fairly easily. Last semester he took a class with me that was very heavy on programming - i.e. 50% of grade was based on programming assignments - long story short, he failed. In the classes where he got a good grade, programming made up only a small fraction of the total grade ~15% (he spent his first 3 years at a different school than mine). He is taking the class over again and again is finding it very hard. This is supposed to be his last semester in school, and if he does pass it, I simply can't see him finding or keeping a job as a software engineer for very long.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  14. #14
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Here's a couple other thoughts regarding a few of the questions.

    - Difference between "C structure" and "C++ structure".

    You need to use the typedef keyword in conjunction with declaration of a C struct and you don't with a C++ struct.

    - Give 2 examples of a code optimization

    These simple examples may qualify rather than writing lengthy specific code examples:

    1) use switch statements instead of complicated if/else if statements

    2) use enums when choice of variable options are limited

    - What is the difference between a pointer and a reference?

    References are declared using the & operator, whereas pointers are declared using the * operator.

    References need to be initialized at declaration. It is wise to do this with pointers, but not necessary.

    References can not be NULL. Pointers can, and frequently will, be NULL.

    The address of a reference is the address of the object to which it points. That is, a reference is another name for the object. The address of a pointer is different than the address held by a pointer, which is the address of the object being pointed to.

    To access the value in a reference you use the same syntax as when referring to the object itself, whereas you need to derefence a pointer using either the * or the -> operator to access the value at the address in the pointer.

    References cannot be declared using dynamic memory, pointers can.
    You're only born perfect.

  15. #15
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    - Difference between "C structure" and "C++ structure".

    how bout a C++ struct can have functions, a C struct can't. (though it can be worked around by using function pointers)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 04:49 PM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Object oriented job questions
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-28-2004, 05:06 AM
  4. Looking for sample MC test questions for a job
    By garp in forum C Programming
    Replies: 2
    Last Post: 09-29-2003, 05:30 AM
  5. I can't find a job.
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 42
    Last Post: 06-29-2003, 08:35 PM