I have an assignment to create a file with number 1-20, and another one with numbers 100-5 decreasing by 5. I've got those two down, but then I need to multiply both those files together one by one and have the answer output to another file. ie: 1*100= 100, 2*95= 190.
Can someone help me with this? I really can't figure it out. This is where I'm stuck:

#include <iostream> 
#include <fstream>
using namespace std;
int main ()
{
	ofstream file1;
	ofstream file2;
	ofstream outfile;

	int a=1,b=100,c=0;

	file1.open("C:\\temp\\file1.txt");{
	while(a<=20){
	file1 << a << " ";
	a++;
	}
}
	file1.close();
	file2.open("C:\\temp\\file2.txt");{
	while(b>0){
	file2 << b << " ";
	b-=5;
	}
	}
	file2.close();
	outfile.open("C:\\temp\\Result.txt");{

	outfile << c;
}
	outfile.close();
	system("pause");
	return 0;
}

Looks like you got a lot of the file I/O handled.. i'll just give ye' a little psuedo to get you on your way:

//Load your files into int[20] arrays
for(int i=0; i<20; i++)
{
     file1 >> array_one[i];
     file2 >> array_two[i];
}

//Multiply each array, element-by-element and save results in an int[20]
for(int i=0; i<20; i++)
{
     results[i] = array_one[i] * array_two[i];
}

//Write results[20] to the output file.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.