troubleshooting Question

Is there a bug in this code?

Avatar of Camillia
CamilliaFlag for United States of America asked on
.NET ProgrammingC#ASP.NET
22 Comments3 Solutions7834 ViewsLast Modified:
I'm taking some online coding tests and came across this one. It says it has bugs in it. I copied it to a console app and it runs fine.

What's wrong with this code?

using System;

public class MathUtils
{
    public static double Average(int a, int b)
    {
        return a + b / 2;
    }
    
    public static void Main(string[] args)
    {
        Console.WriteLine(Average(2, 1));
    }
}
ASKER CERTIFIED SOLUTION
it_saige
Developer
Join our community to see this answer!
Unlock 3 Answers and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros