ok so i have been sitting here for over 2 hours trying to figure out what is wrong with my code and why i keep getting the same 2 error messages

energy part 2.cpp(104) : error C2059: syntax error : ']'
and
energy part 2.cpp(105) : error C2447: '{' : missing function header (old-style formal list?)

and this is my code
the errors are happening in the last bit of my code

#include <iostream>
#include <iomanip>
using namespace std;
int i;
void sort(int[], int[]);
void c(int[], int[]);
int customer[7];
int usagekwh[7];
double cost[7];
int main()
{
	

	for(i=0; i<7; i++)
	{
		cout<<"enter customer number: ";
		cin>>customer[i];

		while(customer[i]<999||customer[i]>10000)
		{
			cout<<"Customer number must contain 4 digits, please reenter number"<<endl;
			cout<<"enter customer number: ";
			cin>>customer[i];
		}
		cout<<"Enter usage in kwh: ";
		cin>>usagekwh[i];
	}
	sort(usagekwh, customer);
	c(usagekwh, customer);
}


void c(int usagekwh[], int customer[])

{
double rate, t;

double total_usage, total_cost, average_cost, average_usage;

	total_cost=0;
	total_usage=0;
	average_cost=0;
	average_usage=0;
	
//ditirmen what rate to be used

for (i=0; i<7; i++)
{
	if (usagekwh[i]<=300)
	{
		rate=0.10;
		t=rate*usagekwh[i];
	}
	else if (usagekwh[i]<800)
	{
		rate=0.09;
		t=30+rate*(usagekwh[i]-300);
	}
	else if (usagekwh[i]<1300)
	{
		rate=0.07;
		t=30+(500*.09)+(rate*(usagekwh[i]-800));
	}
	else
	{
		rate=0.055;
		t=30+(500*.09)+(500*.07)+(rate*(usagekwh[i]-1300));
	}
	//output

	cout<<"Customer    "<<customer[i]<<endl;
	cout<<"Usage       "<<setprecision(2)<<showpoint<<fixed<<usagekwh[i]<<endl;
	cout<<"Amount Due $"<<setprecision(2)<<showpoint<<fixed<<t<<endl;

	cost[i]=t;

}

//compute the totals

for (i=0; i<7; i++)
{
	total_usage=total_usage+usagekwh[i];
	total_cost=total_cost+cost[i];
	
}

average_usage=total_usage/7;
average_cost=total_cost/7;

//output

cout<<"______________________________________________"<<endl;
cout<<"                                 "<<endl;
cout<<setw(9)<<"         "<<setw(10)<<right<<"Usage(kwh)"<<setw(26)<<right<<"Amount Due(dollars)"<<endl;
cout<<"______________________________________________"<<endl;
cout<<setw(9)<<right<<"Total"<<setw(10)<<setprecision(2)<<showpoint<<fixed<<total_usage<<setw(26)<<total_cost<<endl;
cout<<setw(9)<<right<<"Average"<<setw(10)<<setprecision(2)<<showpoint<<fixed<<average_usage<<setw(26)<<average_cost<<endl;
}


void sort(usagekwh[], customer[]);
{
	int holdu, holdc, p, i;

	//nested for loops to cycle thru array
	for(p=o; p<7; p++)
	{
		for(i=0; i<7; i++)
		{
			//if statements
			if(usagekwh[i]<usagekwh[i+1])
			{
				//sort usage
				holdu=usagekwh[i];
				usagekwh[i]=usagekwh[i+1];
				usagekwh[i+1]=holdu;

				//swap customer number

				holdc=customer[i];
				customer[i]=customer[i+1];
				customer[i+1]=holdc;
			}
		}
	}
	return;
}

thanks for ur guys help

Use code tags, please...

I see arrays accessed out of their boundaries (check your two for loops), a p=o that I assume you mistyped for p=0 , a semicolon which shouldn't be there and void sort(usagekwh[], customer[]) missing int before each argument - and that's only after a quick look through the last lines of your code.

Again, use code tags please.

Use code tags, please...

I see arrays accessed out of their boundaries (check your two for loops), a p=o that I assume you mistyped for p=0 , a semicolon which shouldn't be there and void sort(usagekwh[], customer[]) missing int before each argument - and that's only after a quick look through the last lines of your code.

Again, use code tags please.

thanks for the help.
i still have a problem with my sorter. the sorter is soppused to sort the usagekwh in desending order and my output of the program seems to be all garbage and i can't seem to find where in my logic i went wrong.

So horridly formatted, I get lost in all those brackets.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.