Thread: C/C++ Objective questions

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    5

    C/C++ Objective questions

    Hi,

    I am looking for websites for objectives questions for C/C++ like we have exams for objectives.

    It will be good to have list of free objective tests websites. But I am happy to pay if somebody
    know that perticular website is good for objective tests and worth paying.

    Thanks,

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    You mean a website that has some sample test questions?

  3. #3

  4. #4
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by phantomotap View Post
    Assignments designed for an ancient compiler from the previous millenium is hardly relevant..
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    5
    cpjust asked:
    You mean a website that has some sample test questions?
    yes please

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Posting opinions derived from a cursory glance is relevant how? Or, if your prefer the direct approach, read the questions offered before you behave as an imbecile.

    Soma

  7. #7
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by phantomotap View Post
    Posting opinions derived from a cursory glance is relevant how? Or, if your prefer the direct approach, read the questions offered before you behave as an imbecile.

    Soma
    I did read some of the questions in there, the indentation is inconsistent and the code was designed to run in DOS. Also, they use void main several places, and global variables where it isn't necessary, and old header files. That site is a bad place to learn C++ from...
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Question 9 is definitely using "iostream.h" which is "old style".

    Question 31:
    Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.
    Example:

    int *i=0x400 // i points to address 400 *i=0; //set the value of memory location pointed by i.

    Incomplete types are otherwise called uninitialized pointers.
    My understanding of an incomplete type is different.
    An incomplete type is something like this:
    Code:
    struct blah;  // We have not described what is INSIDE blah - just that it's some sort of struct - thus it is incomplete. 
    
    void func(blah *p)
    {
        // We can use p here, as long as we don't try to access it's content.
    }
    Otherwise, I don't see anything directly wrong (although some questions where quite obviously targetting someone who had read some particular book/coursework).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well I did notice this right at the top:
    Note : All the C sample programs are tested under Turbo C/C++ compilers.
    It is assumed that,

    Programs run under DOS environment,
    The underlying machine is an x86 system,
    Program is compiled using Turbo C/C++ compiler.
    Which doesn't instill a lot of confidence in me, and the code formatting really is horrible, but I saw some things that would be useful while skimming over it.

  10. #10
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Programs run under DOS environment
    Yes, and that shouldn't bother you. The note is offered to suggest that one may safely ignore the problems associated with threads/locking/etc..

    The underlying machine is an x86 system
    Would assuming a TI 8533 be more appropriate? Indeed, some questions are hardware dependent; the logic being that understanding the results of undefined behavior can be bloody useful.

    Program is compiled using Turbo C/C++ compiler.
    It didn't actually say what version... but in the context I would assume version 4.0; a compiler that outperforms virtually every compiler from virtually every company, produced over a decade later, in many areas--most notably any mechanics involving conformance of templates. It still outperforms the majority of developer owned compilers for small devices.

    Would it instill more confidence I wonder if the environment listed was Windows and the compiler an unlisted version of MSVC?

    Soma

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well like I said, there were some useful things I saw there. I just wouldn't use it as my only source for studying. Surely there must have been a lot of assignments and notes passed out in the class that would help narrow down what areas would be best to focus on. It wouldn't really be fair for the teacher to ask questions about stuff that wasn't taught.

  12. #12
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    But the answer to the first question is wrong!

    A null pointer assignment cannot occur in that case. The behavior is undefined, but null is not involved. "delete ptr" will not set ptr to null. It will only invalidate the call to *ptr. Odds are the program will still work as intended.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  13. #13
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by phantomotap View Post
    It didn't actually say what version... but in the context I would assume version 4.0; a compiler that outperforms virtually every compiler from virtually every company, produced over a decade later, in many areas--most notably any mechanics involving conformance of templates. It still outperforms the majority of developer owned compilers for small devices.

    Would it instill more confidence I wonder if the environment listed was Windows and the compiler an unlisted version of MSVC?

    Soma
    A decade after it's release is still 5 years ago, no matter how good it was back in 1993 it doesn't comply to the standards anymore. Even some of the answers are wrong, as matsp and king mir pointed out, so i maintain that this guide is of little relevance, but you can just continue calling me an imbecile if you wish...
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by phantomotap View Post
    Yes, and that shouldn't bother you. The note is offered to suggest that one may safely ignore the problems associated with threads/locking/etc..
    On the contrary, it should bother you. We don't live in a DOS age anymore.

    It didn't actually say what version... but in the context I would assume version 4.0; a compiler that outperforms virtually every compiler from virtually every company, produced over a decade later, in many areas--most notably any mechanics involving conformance of templates. It still outperforms the majority of developer owned compilers for small devices.

    Would it instill more confidence I wonder if the environment listed was Windows and the compiler an unlisted version of MSVC?
    As others kindly point out, Turbo C++ is very old, and has poor standards compliance today. It's faster because it's less complex than today's standards require. And therefore, due to bad standards compliance, it shouldn't be used. Not to mention it produced DOS binaries, which adds further limits, such as limited to 640k or so of memory.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    But the answer to the first question is wrong!
    Plus the solution given is not a proper fix to the problem. The solution is to implement the copy constructor and copy assignment operator to perform deep copying, as per the rule of three.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  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. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM