Course Hero Logo

Refer to the code snippet below and sample file data

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 8 - 11 out of 11 pages.

Refer to the code snippet below and sample file data for thenext two (2) questionsifstream ins;ins.open("data.txt");string input;string output;while (ins >> input){if (ins.fail()) {ins.clear();string junk;getline(ins, junk);}else {output = input;}}cout << output;The filedata.txthasthree (3)lines with the following text:5 Zion3 Arches1 Canyonlands13) Given the above code snippet and file data, what prints?A.ZionB.ArchesC.CanyonlandsD. nothing, the code goes into an infinite loopAnswer: C
14) The above code snippet is now modified by changing the data type of variablesinputandoutputfromstringtoint. i.e. the variable declarations become:int input;int output;What will print when the code is executed?
8
Refer to the class declarations below for thenext five (5) questionsclass Hike {public:Hike();Hike(string n, double d);double getDistance();void setDistance(double d);string name;private:double distance;};class NationalPark {public:NationalPark();NationalPark(string n, int a);void addHike(Hike h, int num);private:string name;int area;Hike hikes[10];};15) Suppose we want to add anewnon-default constructor to theNationalParkclass.Which of the following would be a valid declaration for the new constructor?
9
16) How could we create an instance of theNationalParkclass with the following valuesfor it’s data members:"Isle Royale"and2314

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 11 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
DORF

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture