1 Replies - 306 Views - Last Post: 10 February 2018 - 02:21 PM

#1 8Bit Bob   User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 69
  • Joined: 07-February 18

Debug the person above you's code!

Posted 09 February 2018 - 06:52 AM

Just thought this would be a fun little game :)

The rules are simple:

1. The person above you will post a snippet of code that has something wrong with it, you must find what is wrong.

2. If you get it correct, you get to post some incorrect code!

3. Put the language of the code in your post.

4. Try to keep it between 1-3 errors (let's not get to crazy now :P )

5. Put the number of errors in your post.

6. This is a game, don't come here to get your actual code debugged.

I'll start:

C++, 2 errors
#include <iostream>

using namespace std;

int main();
{
    cout << "Hello world! << endl;
    return 0;
}


This post has been edited by 8Bit Bob: 09 February 2018 - 06:52 AM



Replies To: Debug the person above you's code!

#2 ndc85430   User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 851
  • View blog
  • Posts: 3,417
  • Joined: 13-June 14

Re: Debug the person above you's code!

Posted 10 February 2018 - 02:21 PM

OK, I'll bite:

1. There's a semi-colon at the end of line 5.
2. On line 7, the closing double quote for the string is missing.

Here's one in Scala, with 1 error and 1 warning:

object Main extends App {
  val values = Seq(1, 2, 3)

  val maybeFirstEven = values.find { value =>
    value % 2 == 0
  }

  maybeFirstEven match {
    case Some(value) => println(value)
  }

  values = Seq(4, 5, 6)
}



Page 1 of 1