Answers

Question and Answer:

  Home  LINQ

⟩ Write a program using LINQ to find the sum of first 5 prime numbers?

class Program

{

static void Main()

{

int[] MyPrimeNumbers = {1,2,3,5,7};

// Use the Count() and Sum() Standard Query Operators to

// compute the count and total sum respectively

Concole.WriteLine("The sum of first {0} prime number is {1}",

MyPrimeNumbers.Count(), MyPrimeNumbers.Sum());

}

}

 157 views

More Questions for you: