Having problems calling - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Having problems calling

loryrickyloryricky Posts: 4Member
Hello eveyone,

I have to develope a program but I am having trouble calling my functions, can you revise it and see what is wrong please?

Thank you!


#include
using namespace std;

void celcius (double);
void farenheit (double);


int main ()
{
double farenheit = 0;
cout << "Farenheit Celcius" << endl;
cout << "________________________" << endl;

while (farenheit <= 20)
{
cout << farenheit << " " << celcius << endl;
farenheit++;
}

return 0;
}

void celcius (double)
{
double farenheit = 0,
celcius = (farenheit - 32.0)* (9.0 / 5.0) ;

cout << celcius << endl;
}

void farenheit (double)

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Hello eveyone,
    :
    : I have to develope a program but I am having trouble calling my
    : functions, can you revise it and see what is wrong please?
    :
    : Thank you!
    :

    For clarity, avoid using the same name for functions and variables.
    Also, you should distinguish between functions and variables. A variable is a storage-space, while a function is a piece of code that can be called from other code (roughly speaking).
    I'll make some changes to your code (in blue and green). Also, next time please use [leftbr]code[rightbr]-tags to post code.
    farenheit should not be a function, because it just needs to store a value, not do a calculation. In this piece of code, Fahrenheit is a variable used to store a temperature value, whilst celsius is a conversion function that is given the temperature in Fahrenheit as parameter, and returns the temperature in celcius. Therefore, I have also changed the celcius function.


    [code]
    : #include
    : using namespace std;
    :
    : [color=Blue]double [/color]celcius (double);
    : [color=Green]//void farenheit (double);[/color]
    :
    :
    : int main ()
    : {
    : double farenheit = 0;
    : cout << "Fahrenheit Celsius" << endl;
    : cout << "________________________" << endl;
    :
    : while (farenheit <= 20)
    : {
    : cout << farenheit << " " << [color=Blue]celcius(farenheit)[/color] << endl;
    : farenheit ++;
    : }
    :
    : return 0;
    : }
    :
    : [color=Blue]double[/color] celcius (double farenheit)
    : {
    : [color=Green] //double farenheit = 0,[/color]
    [color=Blue]double temp;
    : temp[/color] = (farenheit - 32.0)* (9.0 / 5.0) ;
    :
    : [color=Green]//cout << celcius << endl;[/color]

    [color=Blue]return temp;[/color]
    : }
    :
    : [color=Green]//void farenheit (double)[/color]
    [/code]

    If you have any further questions, let me know.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • loryrickyloryricky Posts: 4Member
    Thank you!!!
Sign In or Register to comment.