Ask Question
30 August, 23:53

Write a function that receives an integer list from STL and returns the sum of even numbers in the list (return zero if no even number is in the list)

+3
Answers (1)
  1. 31 August, 02:06
    0
    int sumeven (int lis[], int n)

    {

    int sum_e=0; //integer variable to store the sum.

    for (int i=0; i
    {

    if (lis[i]%2 = = 0) / /if the number is even adding to sum_e.

    sum_e=sum_e+i;

    }

    return sum_e; //retuning the sum.

    }

    Explanation:

    The above written function is in C++. This function find the sum of even numbers in the list provided. It loops over the array and if the number is even adds to the variable sum_e finally return sum_e which having the sum of even numbers now.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function that receives an integer list from STL and returns the sum of even numbers in the list (return zero if no even number is ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers