Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Problem taken from a C++ quiz

Problem taken from a C++ quiz

Scheduled Pinned Locked Moved Clever Code
questionc++comhelptutorial
25 Posts 15 Posters 35 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jay Gatsby

    This isn't the exact question (I can't remember what it was exactly) but this example keeps to the spirit of the problem. There was a series of questions which had subtle bugs in them, which all had to be answered in the following way: Does it compile? If so, does it run without (potentially) crashing? If so, what does it print out? #include // for cout int main() { int x = 4; int y = 2; int *px = &x; int *py = &y; std::cout << "4 / 2 = " << *px/*py << std::endl; return 0; } When you think you know the answer, go to http://pastebin.com/f57900ce I actually got this one right.

    -Gatsby

    T Offline
    T Offline
    tmalbon
    wrote on last edited by
    #21

    insert space between `/' and '*' like this `*px/ *py << std::endl;" it will compile on VC6

    TMALBONPH

    1 Reply Last reply
    0
    • A Anthony Mushrow

      Seems like a good professor.

      My current favourite word is: Bacon!

      -SK Genius

      B Offline
      B Offline
      bulg
      wrote on last edited by
      #22

      Sounds like an annoying professor

      A 1 Reply Last reply
      0
      • B bulg

        Sounds like an annoying professor

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #23

        Wow, old post, and one voted too. Obviously people don't agree with me :rolleyes: Oh well, i think they seem like a decent proff. anyway, y'all are entitled to your own opinions.

        My current favourite word is: I'm starting to run out of fav. words!

        -SK Genius

        Game Programming articles start -here[^]-

        B 1 Reply Last reply
        0
        • A Anthony Mushrow

          Wow, old post, and one voted too. Obviously people don't agree with me :rolleyes: Oh well, i think they seem like a decent proff. anyway, y'all are entitled to your own opinions.

          My current favourite word is: I'm starting to run out of fav. words!

          -SK Genius

          Game Programming articles start -here[^]-

          B Offline
          B Offline
          bulg
          wrote on last edited by
          #24

          woops, didnt see the date [-1 troll] for me >.<

          1 Reply Last reply
          0
          • L Lost User

            This brings up memories from first and second semester programming courses, like this: int x = 5; int y = 100; int z = 0; int* px = &x; int* py= &y; z = *px**py; Would this execute properly? If yes, what is the value of z after execution?

            modified on Wednesday, April 23, 2008 10:14 AM

            M Offline
            M Offline
            Megidolaon
            wrote on last edited by
            #25

            Stuff like that pisses me off. Might be bad experience, but teachers often feel funny and think they come up with a "good" way of testing the students' knowledge with excessively nested or obscure code. The main reason why it pisses me off is because stuff like that usually never got mentioned before in class. Not even once. Not only that, usually none of the resources mention it either. So the students not only have no reason to ever use something like that, they usually don't even know something like that is even possible. This means they have no idea just what the hell will happen. Thinking it through won't help either because it's not something you can deduct from the stuff you learned, it's only a 50/50 guess whether you get the right answer or not. Might be just my bad experience but I've written too many tests where the larger part was made up of questions like that and the things you really discussed in class and read in the resources made up less than half of it. It was more like guessing the right answers rather than testing the acquired knowledge.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups