need help in function

double getFailureRate(double marks[], int size )
{}
i want to write a function to get failure rate of marks after key in 5 students marks,how to do that?
Take a stab at it yourself, then post what you've come up with.

It's not fair to expect us to do all the heavy lifting for you. (Or to do your homework for you, if that's what it is.)
i have no idea that why i ask it here
You truly have no idea how to begin to write a function? You have no idea how to input marks for 5 students? No notion as to how you could check whether an input score is equal to or greater than the minimum passing score?
i know write the function,failure rate how to make percentage that's the function on me,if got 5 people marks
I can help you only if I can understand your English.. Please write the question in proper English
you have the right function.

alls left is to loop the array inside that function and test each other about your conditions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
double getFailureRate(double marks[], int size ) 
{
	int nFailures = 0;

	int i = 0;
	for (; i < size ; ++ i)
	{
		if(marks[i] < 60)
			++ nFailures;
	}
	
	int rateOfFailures = nFailures / size;
	std::cout << rateOfFailures * 100 << " %" << std::endl;
}
int rateOfFailures = nFailures / size; // *** integer division ***
yep too quick on that one :) use double rateOfFailures , which you can return then.
Topic archived. No new replies allowed.