Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    3

    Unanswered: can someone help me with void functions please C++

    #include <iostream>
    using namespace std;

    //function prototypes
    int getFahrenheit();
    float calcCelsius(int);

    int main()
    {
    //declare variables
    int fahrenheit = 0;
    float celsius = 0.0;

    //get input item
    fahrenheit = getFahrenheit();



    //display output item

    cout << "Celsius is: " << celsius << endl;

    return 0;
    } //end of main function

    //*****program-defined functions*****
    int getFahrenheit()
    {
    int Temp = 0;
    cout << "Enter Fahrenheit Temp: ";
    cin >> Temp;
    return Temp;
    }

    float calcCelsius(int Fahrenheit)
    {
    float temp = 0.0;
    temp = 5.0 / 9.0 * (Fahrenheit - 32);
    return temp;
    } //end of program-defined functions

    I need to put in three void functions for get fahrenheit, calccelcius, and display celsius. can anyone help please? I be on yahoo IM if anyone would like to im me. thanks

  2. #2
    Join Date
    Apr 2003
    Posts
    1
    // try this...


    #include <iostream.h>
    #include <conio.h>
    using namespace std;

    //function prototypes
    int getFahrenheit();
    float calcCelsius(int);

    int main()
    {
    //declare variables
    int fahrenheit = 0;
    float celsius = 0.0;

    //get input item
    fahrenheit = getFahrenheit();

    //calc Celsius
    celsius=calcCelsius(fahrenheit);
    //display output item

    cout << "\nCelsius is: " << celsius << endl;
    getch();
    return 0;
    } //end of main function

    //*****program-defined functions*****
    int getFahrenheit()
    {
    int Temp = 0;
    cout << "Enter Fahrenheit Temp: ";
    cin >> Temp;
    return Temp;
    }

    float calcCelsius(int Fahrenheit)
    {
    float temp = 0.0;
    temp = 5.0 / 9.0 * (Fahrenheit - 32);
    return temp;
    } //end of program-defined functions

    /*I need to put in three void functions for get fahrenheit,
    calccelcius, and display celsius. can anyone help please?
    I be on yahoo IM if anyone would like to im me. thanks



    */

  3. #3
    Join Date
    Apr 2003
    Posts
    2
    Is this what you want ?

    #include <iostream.h>
    using namespace std;

    //function prototypes
    void getFahrenheit();
    void calcCelsius(int);
    void displayCelsius();

    //Global variables
    int Fahrenheit;
    float Celsius;

    int main()
    {
    Fahrenheit = 0;
    Celsius = 0.0;

    //get input item
    getFahrenheit();

    //calculate celsius value
    calcCelsius(Fahrenheit);

    //display output item
    displayCelsius();

    return 0;
    } //end of main function

    //*****program-defined functions*****
    void getFahrenheit()
    {
    int Temp = 0;
    cout << "Enter Fahrenheit Temp: ";
    cin >> Fahrenheit;
    //return Temp;
    }

    void calcCelsius(int Fahrenheitvalue)
    {
    //float temp = 0.0;
    Celsius = 5.0 / 9.0 * (Fahrenheitvalue - 32);
    //return temp;
    }

    void displayCelsius()
    {
    cout << "Celsius is: " << Celsius << endl;
    }//end of program-defined functions

  4. #4
    Join Date
    Apr 2003
    Posts
    3
    tahnk u both so much for your help. I am glad people are out there for help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •