adplus-dvertising
frame-decoration

Question

Select the output for given code snippet:
class Program
{
    static void Main(string[] args)
    {
        int[] nums = { 1, -2, 3, 0, -4, 5 };
        var posNums = from n in nums
                       where n > -5 && n < 6
                       orderby n descending
                       select n;
        Console.Write("The positive values in nums: ");
        foreach (int i in posNums) Console.Write(i + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

a.

Prints nothing code runs successfully

b.

Run time error

c.

Arranged in descending order code runs successfully

d.

Compile time error

Posted under C# programming

Answer: (c).Arranged in descending order code runs successfully

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Select the output for given code snippet: