Ask Question
11 June, 15:33

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)

+1
Answers (1)
  1. 11 June, 17:31
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers