adplus-dvertising
frame-decoration

Question

For the given set of codes, what is the output?
class Program
    {
        static void Main(string[] args)
        {
 
            int[] nums = { 1, -2, -3, 5 };
            var posNums = from n in nums
                          orderby n descending
                          select n*4 / 2;
            Console.Write("The values in nums: ");
            foreach (int i in posNums) Console.Write(i + " ");
            Console.WriteLine();
            Console.ReadLine();
        }
    }

a.

10 2 -4 -6

b.

5 1 -2 -3

c.

1 5 -2 -3

d.

Run time error

Posted under C# programming

Answer: (a).10 2 -4 -6

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. For the given set of codes, what is the output?