Sunday, July 12, 2009

I need help with my C++ program please!!! i am getting this error that i don' know how to fix - help!!?

cannot convert parameter 1 from 'const double' to 'double %26amp;'


this is my code:


#include%26lt;iostream%26gt;


#include %26lt;iomanip%26gt;





using std::cout;


using std::cin;


using std::endl;


using std::setprecision;


using std::fixed;





//fucntion prototype


void getInput(double %26amp;, double %26amp;, double %26amp;);


double calcAverage(double, double, double);





int main ()


{


//decalare variables


const double labAve = .50;


const double quizAve = .20;


const double examAve = .30;


double average = 0.0;


double getAverage = 0.0;





//enter functions to het input items


getInput(labAve, quizAve, examAve);


getAverage = calcAverage(labAve, quizAve, examAve);





//calculate and display average


cout %26lt;%26lt; fixed %26lt;%26lt; setprecision(2);


cout %26lt;%26lt;"Your average is : " %26lt;%26lt; average %26lt;%26lt; endl;





return 0;


} //end of main function





//**program defined functions ****

I need help with my C++ program please!!! i am getting this error that i don' know how to fix - help!!?
Drop the const from your 3 double declarations, you intend these values to be modified. Const precludes them from being modified, and C++ enfoces that you pass the proper const-ness.





Your calcAverage does not need pass-by-reference because it does not need to modify its parameters.
Reply:Do things simple first if it works fine then go to the light advanced level .... Cut down your function take input direct in main function and calculate it by using function as you already did well...........





Then you better re-read arthimetic pointer concept.. if you realy need the function then change your input method declaration and definition to this .....





void input (double *v1,double *v2,double *v3); // declaration





input(%26amp;num,%26amp;num,%26amp;num); // calling





now your function will become


*v1 = %26amp;num , *v2 = %26amp;num2 , *v3 = %26amp;num3





and then think about how to write code about definition....





if you feel problem then you better study pass by address and pass by reference


bye
Reply:May be you can post your requirements at http://expert.gionram.com/


and let many programmers bid for your project.


You can hire whoever you like.





Do not pay any money afront however.

survey software

No comments:

Post a Comment