Answer to Question #211931 in C++ for Dunga

Question #211931

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


1
Expert's answer
2021-06-29T10:23:12-0400
/******************************************************************************
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;
}

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