Make the function comparing two variables with different value print True

-1

Without changing the actual function, call it in such a way that it prints "True"

void Puzzle(out int x, out int y)
{
  x = 0;
  y = 1;
  Console.WriteLine(x == y);
}

Online Tester

dav

Posted 2015-03-17T06:12:46.323

Reputation: 17

Question was closed 2015-04-27T11:57:04.557

2Programming puzzle challenges should usually include some indication how the "best" answer is chosen is several valid solutions are posted. – Martin Ender – 2015-03-17T09:08:41.307

Answers

5

Reusing reference:

//C# Puzzle: Call the Puzzle() function in Main such that it prints True. 
//You have to do this without changing the Puzzle method.

public void Main()
{
  int x,y;
  Puzzle(out x, out x);
}

void Puzzle(out int x, out int y)
{
    x = 0;
    y = 1;
    Console.WriteLine (x == y);
}

Ming-Tang

Posted 2015-03-17T06:12:46.323

Reputation: 5 383

4

claster

Posted 2015-03-17T06:12:46.323

Reputation: 41