Question

Code the following in C++ #include <iostream> int main() { the array below represents 10 sales for 100 days fill the array wi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ Code:-

#include<bits/stdc++.h>
using namespace std;
void PrintDailySales(double sales[100][10])
{
for(int i=0;i<100;i++)
{
double sum=0.0;
for(int j=0;j<10;j++)
sum+=sales[i][j];
double avg=sum/10.0;
cout<<"Average Sale Day "<<i+1<<" : "<<avg<<endl;
}
}

int main()
{
// The array represents 10 sales for 100 days.
double sales[100][10];
  
// Filling the array with random doubles between 6.5 to 1005.5
// you can create the number in any range. I used this for simplicity.
for(int i=0;i<100;i++)
{
for(int j=0;j<10;j++)
sales[i][j]=rand()%1000+6.5;
}
  
// Calling function to print the average sale per day.
PrintDailySales(sales);
return 0;
}

5 6 8 } main.cpp 1 #include<bits/stdc++.h> 2 using namespace std; void PrintDailysales(double sales[100][10]) 4-{ for(int i=0input Average Sale Day 1 : 610.2 Average Sale Day 2 : 476.6 Average Sale Day 3 : 413.9 Average Sale Day 4 : 301.4 Average SalAverage Sale Day 39 : 674.6 Average Sale Day 40 : 501.9 Average Sale Day 41 : 586.3 Average Sale Day 42 : 533.6 Average SaleAverage Sale Day 76 : 505 Average Sale Day 77 : 324.7 Average Sale Day 78 : 455.1 Average Sale Day 79 : 477 Average Sale Day

Add a comment
Know the answer?
Add Answer to:
Code the following in C++ #include <iostream> int main() { the array below represents 10 sales...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT