so i have been sitting here for about 2 days finishing this thing and i still have one error left and i am having a hard time fixing it

1>k:\c++\energy bill part 3\energy part 2.cpp(119) : error C2059: syntax error : ';'

here is my code

thanks for your help

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int i;
void sort(int[], int[], string[], int);
void c(int[], int[], int);
int customer[25];
int usagekwh[25];
double cost[25];
int arraysize;
string name[25];

int main()
{
	cout<<"enter the number of customers being processed";
	cin>>arraysize;

	ifstream names("K:\C++\energy bill part 3\input.txt", ios::in);
	if (!names){
		cerr << "File could not be opened\n";
		exit(1);
	}
	for (i=0; i<50; i++)
	{
		//cout<<"i has top value:"<<i<<endl;
		names>>customer[i];
		//cout<<account[i]<<endl;
		//read the name
		names.ignore(1);
		getline(names,name[i]);
		

		
		


	}

	sort(usagekwh, customer, name, arraysize);
	c(usagekwh, customer, arraysize);
}


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

{
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<arraysize; 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(int usagekwh[], int customer[], string name[], int arraysize)
{
	int holdu, holdc, p, i,;
	string holdn;

	//nested for loops to cycle thru array
	for(p=0; p<arraysize; p++)
	{
		for(i=0; i<(arraysize-1); i++)
		{
			//if statements
			if(customer[i]>customer[i+1])
			{
				//switch usage
				holdu=usagekwh[i];
				usagekwh[i]=usagekwh[i+1];
				usagekwh[i+1]=holdu;

				//switch customer number
				holdc=customer[i];
				customer[i]=customer[i+1];
				customer[i+1]=holdc;

				//switch names
				holdn=name[i];
				name[i]=name[i+1];
				name[i+1]=holdn;

			}
		}
	}
	return;
}

Neither you nor your compiler are being very helpful. Please give some idea about where line 119 is in your code. That's the first place to look. It may not end up being the place with the error, but chances are it's in that neck of the woods.

I could take a stab at it and point out the last comma in this line is superfluous which is another way of saying the semicolon is unexpected, but such a stab is likely to be wrong.

int holdu, holdc, p, i,;

i add the line numbers but they are off by 2 so line 100 is actually 102

your stab was right thanks for your help

On this line:

int holdu, holdc, p, i,;

take out the comma after the i:

int holdu, holdc, p, i;
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.