adplus-dvertising
frame-decoration

Question

What will be the output of the given code snippet?
class Program
{
    static void Main(string[] args)
    {
        Expression<Func<int, int, bool>>
        IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
        Func<int, int, bool> IsFactor = IsFactorExp.Compile();
        if (IsFactor(10, 5))
        Console.WriteLine("5 is a factor of 10.");
        if (!IsFactor(343, 7))
        Console.WriteLine("7 is not a factor of 10.");
        Console.ReadLine();
    }
}

a.

Compile time error

b.

Run time error

c.

5 is a factor of 10
7 is not a factor of 10

d.

5 is a factor of 10

Posted under C# programming

Answer: (d).5 is a factor of 10

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the given code snippet?