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, 0, -4, 5 };
         var posNums = nums.Where(n => n < 10).Select(r => r%3);
         Console.Write("The values in nums: ");
         foreach (int i in posNums) Console.Write(i + " ");
         Console.WriteLine();
         Console.ReadLine();
     }
 }

a.

Compile time error

b.

Run time error

c.

1 -2 0 0 -1 2

d.

2 -1 0 0 -2 1

Posted under C# programming

Answer: (c).1 -2 0 0 -1 2

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?