Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following statement will format the output of decimal numbers to three decim

ID: 3846288 • Letter: T

Question

The following statement will format the output of decimal numbers to three decimal places.

cout << setprecision(3);

To force the output to show the decimal point and trailing zeros of a decimal number, use the ____________________ manipulator.

The setw manipulator cannot use a string as an argument.

The header file ____________________ needs to be included to use the setw function.

Unlike the cin and cout variables of iostream, file stream variables must be declared by the programmer.

File I/O is a five-step process: Please match the step with the description.

Step 1

      [ Choose ]            Declare file stream variables            Use the file stream variables with <<, >> or other I/O functions.            Include the header file "fstream" in the program            Associate the file stream variable with the I/O sources.            Close the files            Add spaces to the variable names      

Step 2

      [ Choose ]            Declare file stream variables            Use the file stream variables with <<, >> or other I/O functions.            Include the header file "fstream" in the program            Associate the file stream variable with the I/O sources.            Close the files            Add spaces to the variable names      

Step 3

      [ Choose ]            Declare file stream variables            Use the file stream variables with <<, >> or other I/O functions.            Include the header file "fstream" in the program            Associate the file stream variable with the I/O sources.            Close the files            Add spaces to the variable names      

Step 4

      [ Choose ]            Declare file stream variables            Use the file stream variables with <<, >> or other I/O functions.            Include the header file "fstream" in the program            Associate the file stream variable with the I/O sources.            Close the files            Add spaces to the variable names      

Step 5

      [ Choose ]            Declare file stream variables            Use the file stream variables with <<, >> or other I/O functions.            Include the header file "fstream" in the program            Associate the file stream variable with the I/O sources.            Close the files            Add spaces to the variable names   

A file (or data file) is an area in secondary storage used to hold information.

File stream variables are predefined in the fstream header file and associated with input/output sources.

The stream member function ____________________ is used to open files.

The following statement "outData.close();" closes the file stream outData.

Write a one line of C++ code using "cin" that gets first name, last name, age (as integer), height (as float), and date of birth (as string). You don't have to declare the variables, just write the one line of code.

Write a one line of C++ code that produces the following output. NOTE: you must use "Text Manipulators" from <iomanip> and not "hard coded" characters.

True

Explanation / Answer

1. True since setprecision(d) is a manipulator used to set the precision of d decimal points.

2. showpoint manipulator is used to show trailing decimal point and zeroes

3. True , argument of setw is an integer used to set the width of the output

4. iomanip is the header file included to use all the manipulators

5. False , filestream variables such as ifstream and ofstream are predefined in the header file

6. Step 1 - Include the header file "fstream" in the program

Step 2 -  Declare file stream variables

Step 3 - Associate the file stream variable with the I/O sources.

Step 4 - Use the file stream variables with <<, >> or other I/O functions.

Step 5 - Close the file

7. True beacuse file is an area used to store data that can be used any time

8. True ifstream and ofstream are the objects that are predefined in the haeder file fstream

9. open is a member function used to open the file with filename as an argument to the function

10. True , close() is the member function used to close the file

11. cin>>firstName>>lastName>>age>>height>>dob;

12. cout<<left<<setw(10)<<setfill('-')<<"1 year"<<setw(1)<<"|"<<right<<setw(12)<<setfill('.')<<"15 years";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote