Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Does anyone know how to go about answering these questions, a basic explanation of how to come about these answers would be greatly appreciated.I have

Does anyone know how to go about answering these questions, a basic explanation of how to come about these answers would be greatly appreciated.I have bolded the questions with the answers below. I just am not getting the correct answers when I try to run through these in my head myself.

Question 1.

long a_fn ( long t , long e ) {

return e * e + t ; }

long fn6 ( vector & v ) {

return accumulate ( v . begin () , v . end () , 0 , a_fn ); }

If vector v = {1, 2, 3, 4}, what is the result of calling fn6(v)? The answer is 30

Question 2.

long fn7 ( const vector < vector >& v ) {

long result = 0;

for ( auto r : v ) {

for ( auto c : r ) {

if ( c % 2) result += c ; } }

return result ; }

If vector> v = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, what is the result of calling fn7(v)? 25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions