messy function that calculates values
-
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks. -
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks. -
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks. -
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks. -
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks.bhangie wrote: d = 20.4; This variable has not been declared. I assume it is a
double
(orfloat
). bhangie wrote: if(*a = 0) Variablea
is being passed as a reference toCalculateValues()
. Therefore,*a
is an incorrect reference since a pointer was not passed toCalculateValues()
. bhangie wrote: c = a + d; Different types are being operated on here. You'll probably need to cast thefloat
"down to" anint
. bhangie wrote: c = a - b + d; Again, different types are being operated on here. Variableb
is a pointer, whereasa
andd
are not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hi before any one start slandering me about this code i did not write it(DID NOT). It is a Question :) well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help. The question is(from Lecturer) (i) Rewrite the following piece of code correcting all the problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c) { d = 20.4; if(*a = 0) { *a += 1; c = a + d; } else { b = c / d; c = a - b + d; } }
Included a Hint: if a=4, b=0.0, c=5 When funct return should be: a=4, b=0.25 and c=24.15. Need help with the prototype and calculations PLEASE:( Many Thanks.#include #include using namespace std; void CalculateValues(const int &a, double *b, double &c) //c only can be double,if float,then *b=c/d how to transfer from float to double {c=5; double d = 20.4;//only double. if(a == 0) { //*a += 1;//error c = a + d; } else { *b = c / d; c =a - *b +d; cout<<"a="<