Write a c++ program that writes sales values from an array to a notepad file and calculate the sales values' total. The sales values are 1200.56, 7800.45, 7888.45 and 4550.89
/******************************************************************************
Write a c++ program that writes sales values from an array to a notepad file and
calculate the sales values' total.
The sales values are 1200.56, 7800.45, 7888.45 and 4550.89
*******************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
double array1[4]={1200.56,7800.45,7888.45,4550.89};
ofstream fout ("output.txt");
double sum=0;
for(int i=0;i<4;i++){
sum=sum+array1[i];
fout<<array1[i]<<"\n";
}
fout<<"\n\t\t\tTotal Sales = "<<sum;
return 0;
}
Comments
Leave a comment