Question: Array Initializer Must Be On Initializer List Program compiled in one complier but not aaother. I know there are others ways to get the same

Array Initializer Must Be On Initializer List

Program compiled in one complier but not aaother. I know there are others ways to get the same answer. I don't want to use an array for the months.

#include

#include

using namespace std;

const int MONTHS = 12;

double getMonth(double[MONTHS]);

string month(int numMonth);

double calcMonth(double[MONTHS]);//Adds up each month

double lowestMonth(double[MONTHS],double low);

int main()

{

double mon[MONTHS];//Store each month

int v[24];

int n=0;

double showMonths= getMonth(mon);//Starts program and gets each month

double calc=calcMonth(mon);//Add up each month

double low=mon[0];

string m[24]=month(n++);

string listL=m[0];

cout<<"Total rainfall: "<

cout<

cout<<"Month"<<"\t"<<"Rainfall"<

cout<<"-----------------------"<

for(int i=0; i

{ //Display each month and the rainfall for it

cout<

if(mon[i]

{

low=mon[i];

listL=m[i];

}

}

cout<

cout<

system("pause");

return 0;

}

double getMonth(double mon[MONTHS])

{

int tot = 0;

for (int i = 0; i

{

//month[numMonth++]

//In order to get each months, month[i]

//is equal

cout << "How much is " << month(i) << "? ";

cin >> mon[i];

tot = mon[i];

}

return tot;

}

string month(int numMonth)

{

if (numMonth == 0)

{

return "Jan";

}

if (numMonth == 1)

{

return "Feb";

}

if (numMonth == 2)

{

return "Mar";

}

if (numMonth == 3)

{

return "Apr";

}

if (numMonth == 4)

{

return "May";

}

if (numMonth == 5)

{

return "Jun";

}

if (numMonth == 6)

{

return "Jul";

}

if (numMonth == 7)

{

return "Aug";

}

if (numMonth == 8)

{

return "Sep";

}

if (numMonth == 9)

{

return "Oct";

}

if (numMonth == 10)

{

return "Nov";

}

if (numMonth == 11)

{

return "Dec";

}

}

double calcMonth(double mon[MONTHS])

{

double tot=0;

for(int i=0; i

{

tot+=mon[i];

}

return tot;

}

double lowestMonth(double mon[MONTHS],double low)

{

double tot=0;

low=mon[0];

for(int i=0; i

{

if(mon[i]

{

low=mon[i];

tot=low;

}

}

return tot;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!