Answer to Question #20738 in C++ for ahmed

Question #20738
write aprogram to read tow numbers at atime from the file and print the product to another file
1
Expert's answer
2012-12-20T07:43:50-0500

#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
& FILE *f;
int dat;
& srand(time(0));
& int n=rand()%30;
& cout << "File name? ";
& char s[20];
& cin>>s;
& f=fopen(s, "wb");
& for (int i=1; i<=n; i++)
& { dat = rand()%101 - 50;
cout << dat << " ";
fwrite(&dat, sizeof(int), 1, f);
& }
& cout << endl;
& fclose(f);
system("PAUSE");
return EXIT_SUCCESS;
}

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
APPROVED BY CLIENTS