Just a helpful tip while you're on this forum:
In the future, please name your thread something relevant to your topic. "Need C++ help quick", in addition to seeming a little rude, tells us absolutely nothing about what you need help with. I mean, come on... it's a little obvious. You're starting a post in the C/C++ forum, so I wouldn't expect you'd need help rebuilding a carburetor or something....
alc6379
Cookie... That's it
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
never rush through coding, it only leads to errors.
Think first, code last.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
I have to get the total votes and percent of each vote for this program.I cant figure it out!
There are a couple of syntax errors.
float percent(int totalVotes[8])
{
int row=0;
int sum=0;
//{ // unnecessary mismatched {
for (row = 0; row < 8; row++)
{
sum=sum+totalVotes[row];
}
return sum/8.0;
}
void printData (int votes[8],char names[8][20],int totVotes,float per )
{
ofstream outputFile;
outputFile.open("output.txt");
int row;
for (row = 0; row < 8; row++)
{
outputFile<<names[row] << " ";
outputFile<<votes[row] <<endl;
//outputFile<<per[row]<<endl; // per is not an array
}
outputFile<<"Total Votes:"<<totVotes<<endl;
outputFile.close();
}
But let's look at this.
int main()
{
int votes[8];
char names[8][20];
int totVotes;
float per;
totVotes=totalVotes(votes);
per=percent(votes);
getData(votes,names);
printData(votes,names,totVotes,per);
return 0;
}
Calculate the results, then get the data?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
To me that semed a little rude to someone new to the board, just asking for a little help.
Not meaning to sound rude at all. I'm just stating the obvious there, and in fact showing you what we're all about. We're here to help, so you don't need to ask for it! :D I'm just making a silly example as to why you don't need to say you need C++ help when you're posting in the C++ forum, really.
alc6379
Cookie... That's it
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147