Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Questions Part 3 18) Show (pseudo)code for a common loop for opening an output file. (Do not allow fancy exiting conditions. If the user

C++ Questions Part 3

image text in transcribedimage text in transcribedimage text in transcribed

18) Show (pseudo)code for a common loop for opening an output file. (Do not allow fancy exiting conditions. If the user wants to exit, they can hit Control-C.) (Do not worry about overwrite vs append, either.) (What kind of loop would be most appropriate?) (Hint: What two things are commonly forgotten in a file opening loop?) 19) Show (pseudojoode for a "read til end of file loop. (What kind of loop would be most appropriate? Where is/are the reading statement(s)? Where is the processing of the read data?) Does the stream involved in your eof loop have to be an input file stream or can it be cin? 20) Given the following Sum function object class: class Sum double sum; public: Sun(double s = 0.0) : sum(s) { } double operator() (double num) { return sum += num; } double operatorO (void) const f return sum; double reset(double s = 0.9) { swap(sum, s); return s; } // create // update // access // [re] initialize Show how to use it to calculate the average of the elements in the following array. (What kind of loop would be most appropriate?) (The declarations are normative;the initializations are illustrative.) const size_t MAX = 50; long a[MAX] ={ 10, 14, 12, 8, 10, 6, 9, 13, 7, 11 }; size_t num-as 10; What would be necessary if the programmer wanted to re-use the same function object to average a second array? Say this one: double b[MAX2] = { 4.4, 9.6, 7.2, 9.4, 6.3, s.1 }; size_t num-bs 6

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

More Books

Students also viewed these Databases questions

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago