Thread: can somoene correct this for me?

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    10

    can somoene correct this for me?

    this is NOT homework.. can some atleast tell me how many I got wrong? appreciate it.

    I'm also curious on problem #2 shouldn't it read: Overloading "Having multiple functions with identical names but different parameter lists" ??


    thanks


    1.

    Code:
    var i = 7;
                    while(i % 3 != 0){
                                    i += 7;
    }
                    print(i);
    What value will be printed?
    21

    2. Overloading is
    a) Running the computer out of memory
    b) Having multiple functions with identical names but different arguments
    c) Having multiple threads access one memory address at the same time
    d) Assigning a new data type to a variable
    e) Redefining a function of a parent class in a child class

    B

    3. int integer = 5;
    print(++integer * integer--);
    What value will be printed?

    36


    4. A recursive function MUST have....
    a) A call to itself e) Polymorphism
    b) A return value f) All of the above
    c) An exit condition g) A and C
    d) Inheritance

    G


    5. Normally, which corner of a frame (window) is considered (0,0)?
    a) Top Left c) Bottom Left
    b) Top Right d) Bottom Right

    A

    6. The result of
    Code:
     i = ((int)((string)((int)"7")+"5"))
    a) An integer i, where i = 12 c) A String, i where i = 75
    b) A String, i where i = 12 d) An integer i, where i = 75

    D


    7. Which of these is not a real differentiator for programming languages?
    a) Object-oriented / Process-Oriented e) All of the above
    b) Interactive / Automated f) B and C
    c) Interpreted / Compiled g) B and D
    d) Strongly-Typed / Weakly-Typed

    B


    8.
    Code:
    int i;
                    int j = 0;
                    for (i=100; j<5; i=i)j = 100-(i-=1);
                    Print i;
    What is the final value of i = 95

    and how many times is i printed? one time

    9. What is the logical operation X if it behaves as follows:
    True X True = False
    True X False = True
    False X True = True
    False X False = False

    a)AND c)OR
    b)NOT d)XOR

    D

    10. What data structure has a single pointer to node and in terns, that node has a single pointer to an inner node?

    a) (Singly) Linked List
    b) Doubly Linked List
    c) Tree
    d) Dictionary
    e) Two-Dimensional Array

    D

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,730
    1. Write a program and run it to check.

    2.
    Quote Originally Posted by markraz
    I'm also curious on problem #2 shouldn't it read: Overloading "Having multiple functions with identical names but different parameter lists" ??
    Yes, that sounds like it caters for the fact that arguments can differ in number and type.

    3. This is a trick question. The behaviour is undefined. However, it looks like despite you asking this question in the C++ programming forum, you might not be dealing with C++, so perhaps the real answer is: it depends.

    4. I might quibble over the details, but I think your answer is what was expected.

    5. I would read the relevant documentation rather than assume "normally".

    6. Is this even supposed to be C++?

    7. Is this even a real question?

    8. Write a program and run it to check.

    9. Yes.

    10. I think the question is badly phrased.
    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

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,729
    Quote Originally Posted by markraz View Post
    6. The result of
    Code:
     i = ((int)((string)((int)"7")+"5"))
    a) An integer i, where i = 12 c) A String, i where i = 75
    b) A String, i where i = 12 d) An integer i, where i = 75

    D
    The correct answer is "E) This code is wrong and makes no sense". What is "string"? Is it "std::string"? Is it pseudocode for "char*" or "const char*". These exercises are all over the place!...
    Last edited by GReaper; 09-07-2015 at 01:34 PM.
    Devoted my life to programming...

  4. #4
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by GReaper View Post
    The correct answer is "E) This code is wrong and makes no sense". What is "string"? Is it "std::string"? Is it pseudocode for "char*" or "const char*". These exercises are all over the place!...
    It's even weirder when you consider that the type of a variable is decided at the declaration. It would make more sense as just an expression and not an assignment, something like:

    Code:
    std::cout << (std::stoi(std::to_string(7) + "5")) << "\n";
    Something like that, maybe those function names make it too apparent what's going on though.
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

  5. #5
    Registered User
    Join Date
    Jul 2015
    Posts
    10
    thanks guys.. I thought the same as you.. these are actually Job interview questions... do you believe it? I was dumbfounded

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So you actually have transcend the C++ language and code in (C++)+ to actually get job? 'kay.
    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.

  7. #7
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by markraz View Post
    thanks guys.. I thought the same as you.. these are actually Job interview questions... do you believe it? I was dumbfounded
    I can believe it, it sounds exactly like a teacher I had in school. He (the teacher) would make tests with the most weirdly worded questions I've ever seen. I wish I had kept some, so that I would have an example, but our entire class was doing so badly that eventually another teacher had to order (or maybe make) some more standard tests.

    The worst part wasn't bad grades (I don't care that much about them), it was the loss in knowledge from all the time spent concentrating on how the tests might be worded instead of really learning the subject. Even years later the bad impression left is tangible. I'm just saying you may want to consider passing this job by, if at all possible. Working for someone who is vague in what they want from you will be like walking on eggshells everyday.
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the IF not sure if this is correct
    By bartsimpsong in forum C Programming
    Replies: 4
    Last Post: 11-26-2009, 02:14 AM
  2. which one is correct
    By BEN10 in forum General Discussions
    Replies: 21
    Last Post: 09-06-2009, 11:37 PM
  3. Correct way of doing this?
    By carrotcake1029 in forum C Programming
    Replies: 12
    Last Post: 04-09-2008, 04:26 AM
  4. Is this correct?
    By patron in forum C Programming
    Replies: 2
    Last Post: 02-18-2008, 11:03 AM
  5. is it correct.. ??
    By vivek_kumbhar in forum C Programming
    Replies: 12
    Last Post: 11-02-2002, 05:03 AM