64 679
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #27553 in C++ for rattypie

Question #27553
Using a while loop, write a C++ program that prompts the user to enter five numbers. As each number is entered the program should write the number into a file named user.txt Using a while loop, write a C++ program that reads the data in the user.txt file created above and displays each individual data item
Expert's answer

#include <fstream>

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
double a[5];
ofstream fout("user.txt");
int i=0;
while(i<5){
cin>>a[i];
fout <<a[i]<<endl;
i++;
}
fout.close();



char buff[50];
ifstream fin("user.txt");
int j=0;
while(j<5){
fin >> buff;
cout << buff << endl;
j++;
& }
fin.close();
int kl;
cin>>kl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions