What will be stored in the file out.dat after the following
#include <iostream>
#include <fstreara>
#include <iomanip>
using namespace std;
int main()
{
const int SIZE = 5;
ofstream outFile("out.dat");
double nums[ ] = {100.279, 1.719, 8.602, 7.777, 5.099};
outFile << setprecision(2);
for (int count = 0; count < SIZE; count++)
{
outFile << setw(8) << nums[count];
}
outFile.close();
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Mechanics of Materials (10th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- C++ Write a code segment that creates an ofstream object named outfile, opens a file named numfile.txt, and associates it with outfile. Then write the contents of the variable data to the file, followed by a newline, then close the file.arrow_forwardFor c++ pleasearrow_forward. In c write a program that:a) takes an input file name from the command line;b) opens that file if possible;c) declares a C struct with three variables; these will have data types thatcorrespond to the data types read from the file (i.e. string, int, float);d) declares an array of C structs (i.e. the same struct type declared in point c);e) reads a record from the file and stores the values read into the appropriatestruct variable at the appropriate array index (for that record);f) continues reading each record into a struct (as in point 1e), and stores eachstruct containing the 3 values into the array of structs declared in point d;g) closes the file when all records have been read.Note that your program should print an error message in the event that the filecannot be opened successfully.arrow_forward
- Q1:- Passing by reference (z, j )using pointers when a= 54 , b=45 show me (1) a ,b before swap.(2)a,b after swap. call me your status. * 1 Add filearrow_forwardFinish the C++ code. Will upvote! thank youarrow_forwardFile Handling with Array: C++ Language: Write a c++ program to read the data from the file into array and do calculation. Note: Take a general word problem which helps in others related questions.arrow_forward
- C++ Progrmaing Instructions Redo Programming Exercise 6 of Chapter 8 using dynamic arrays. The instructions have been posted for your convenience. The history teacher at your school needs help in grading a True/False test. The students’ IDs and test answers are stored in a file. The first entry in the file contains answers to the test in the form: TFFTFFTTTTFFTFTFTFTT Every other entry in the file is the student ID, followed by a blank, followed by the student’s responses. For example, the entry: ABC54301 TFTFTFTT TFTFTFFTTFT indicates that the student ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is False, and so on. This student did not answer question 9 (note the empty space). The exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points. Write a program that processes the test data. The output should be the student’s ID,…arrow_forwardLanguage: C++ Create a class called publication that stores the title (char array) and price (float) of a publication. From this class derive two classes: book, which adds a page count (int) and tape, which adds a playing time in minutes (float). Each of the three classes should have a getdata() function to get its data from the user using input from the keyboard and a putdata() function to display the data.Write a main function that creates an array of pointers to publication. In a loop, ask the user for data about a particular type of book or tape to hold data. Put the pointer to the object in the array. When the user has finished entering data for all the books and tapes, display the resulting data for all the books and tapes entered, using a for loop and a single statement such as: pubarr[j] -> putdata(); To display the data from each object in the array.arrow_forwardFinish the C++ code. Suppose the file nums.txt contains the following data:arrow_forward
- #include #include #include #include #include #include void dft(uint8_t*, double*, int); void dft print(double, int, double); #define N 512 int main(int argc, char **argv) { char *port = argv[1]; /* Open the file */ int fd = open(port, O_RDONLY); // code to set communication rate to 9600 bits per second struct termios tio; tcgetattr(fd, &tio); cfset speed(&tio, B9600); tcsetattr(fd, 0, &tio); // reopen the serial port so that the speed change takes effect close(fd); fd = open(port, O_RDONLY); if (fd #include #include #include void dft(uint8_t* x, double* X, int N) { double Xr[N]; double Xi[N]; for (int k=0; k 70) count = 70; printf("%031d", Irint (bounds[k]*fs/N)); for (int j=0; j < count; j++) { } } printf("*"); printf("\n"); for (int k=0; k < NBUCKETS; k++) { printf("\033[A"); } }arrow_forwardProgramming Assignment 1 #include <iostream> #include<iomanip> #include<fstream> #include<sstream> #include<string.h> using namespace std; //Define the main function int main() { //Create the object of fstream class and opening the file ifstream inpfile("order.txt"); string fline; double sub_total, tax, shipping=14.95, grand_total, line_total; double priceA=17.46, priceB=10.13, priceC=2.11, priceD=23.13, priceE=74.56, priceF=1.11, priceG=9.34, priceH=3.45; cout<<"Thank You! Your order is summarized below: "<<endl; cout<<"-----------------------------------------------"<<endl; cout<<"| Product\t|Quantity\t|Line total |"<<endl; cout<<"-----------------------------------------------"<<endl; while (getline(inpfile, fline)) { istringstream ists(fline); string product; int quantity; if (!(ists >>product>> quantity)) {…arrow_forwardSUBJECT NAME IS C++: WAP to read 4 student objects and write them into a file, then print total number of student number in file. After that read an integer and print details of student stored at this number in the file using random access and file manipulatorsarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning