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
1
Expert's answer
2013-04-09T09:13:39-0400

#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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS