Can someone please assist me in this c++ problem below?, thanks
Write program that keeps daily sales of 10 stores in an array and determine
a) Highest sale and the store number (assume that the first store has the store
number zero)
b) Lowest sale and the store number
c) Average sale
#include <iostream> using namespace std; int main() { float arr[10], sum = 0; int n = 10, min, max; cout<<"Enter daily sales of 10 stores:"<<endl; for(int i = 0;i<n;i++){ cin>>arr[i]; } min = 0; for(int i = 1;i<n;i++){ sum += arr[i]; if(arr[min] > arr[i]){ min = i; } } max = 0; for(int i = 1;i<n;i++){ if(arr[max] < arr[i]){ max = i; } } cout<<"Array: "; for(int i = 0;i<n;i++){ cout<<arr[i]<<" "; } cout<<endl; cout<<"Highest sale is "<<arr[max]<<" and the store number is "<<max<<endl; cout<<"Lowest sale is "<<arr[min]<<" and the store number is "<<min<<endl; cout<<"Average sale = "<<(sum/10.0)<<endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.