Any help would be greatly appreciated. The program I am trying to write is a program that takes reads from a text file. In the txt file is five names and their votes. Im trying to get the total amount of votes and their percentage. I feel like I am close to doing it,but I keep getting errors in this section, as far as the 'percent' and the 'total':
line 22 you use "total" without having defined it. Is it an int, a double, ... ?
The "percentage" function you're calling line 23 does not exist.
The existing "percentage" function has several problems :
- The variable "percent" is not defined in the function
- It's supposed to return a double, but if percent is an array, it's a double*
- The prototype of the "percentage" function defines total as an array. According to your code it's a single value, not an array.
- line 62 there's a missing parenthese
- It does not return the winner.
line 25, [winner] doesn't mean anything, I suppose you intended to write winner
In my 'percentage' function, what am I doing wrong with the 'percent' variable?
"percent" is not declared in the function.
From what I understand it's supposed to be an array in which you store the percentage of the votes each candidate has. I also suppose that you intend to store the percentages in the "percent" array defined in your main().
That means you have to pass it as an argument to the function. The prototype should therefore be something like double percentage(double votes, double total, double percent).
There is also the problem of the return value. The function is supposed to return a double, but you return "percent" which is not a double.
Personally I don't think this function should return anything.