value-returning function

The problem is;"getting lots of [WARNING] and cannot convet errors"

If you did not pass a module no busary.
If you did pass 1 or 2 moduls and is registerd for at leas 1 module R300
otherwise : the bursary is equal to (number of modules passed + number modules
registerd) * 100

float bursary (float pass, float registerd)
{
if (pass >= 3 && registerd >= 1)
reurn (pass + registerd) * 100;
else if (pass >= 1 && registerd >= 1)
return 300 ;
else if (pass == 0)
return 0;
}

intmain ( )
float bursary, pass, registerd, total;
cout << "Pleas enter the modules pass :";
cin >> pass;
cout << "Pleas enter the modules registerd:";
cin >> registerd;
total = busary (pass, registerd)
Ok, not sure if the typo's are when you are pasting the code or not..

In function bursary;
if pass >0 and registered <1 then there is no return statement. You should make sure there is always a return value.
pass and registerd are declared as float, but you are comparing then to integers, and the desription suggest they will always be integers. A good rule of thumb is to always use integers unless you need floats.
The same applies to function bursary itself.
The convert errors may be due to combining floats and ints, returning ints (300 is an integer, 300.0 is a float), etc.

In main
You are missing the {} arround the code.
You should not declare a variable bursary when you have a function bursary()
I guess you also want to cout << total :-)


Topic archived. No new replies allowed.