Question

Create a function NumEven( std: forward_list-int> SList) that computes and returns the number of even values in a singly link[ Select] for (int i; i < num; i++) { if (n / 2 == 0) num-- ; } return num; unsigned num = 0; for (auto n: SList) { if (n % 2

All in C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION:

As the function needs to return unsigned number so declare unsigned num = 0;
Now we need to iterate through list and check the number is divisible by 2 using mod increment num for (auto n: SList ){ if (n % 2 == 0) num++; }
Now return num;

Remaining are wrong statements.

I have provided the code and output for a clear view.

The 3 statements to be filled are :

unsigned num = 0;

for (auto n: SList ){ if (n % 2 == 0) num++; }

return num;

CODE ATTACHMENTS:

5 6 7 8 9 10 11 12 13 14 15 16 17 #include<iostream> #include<forward_list> unsigned NumEven(std::forward_list<int> Slist) {

Please do comment for any queries.
Please like it.
Thank you.

Add a comment
Know the answer?
Add Answer to:
All in C++ Create a function NumEven( std: forward_list-int> SList) that computes and returns the number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT