If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > can someone help me with void functions please C++

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-03, 19:01
john67elco john67elco is offline
Registered User
 
Join Date: Apr 2003
Posts: 3
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
Reply With Quote
  #2 (permalink)  
Old 04-23-03, 06:10
jensr jensr is offline
Registered User
 
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



*/
Reply With Quote
  #3 (permalink)  
Old 04-23-03, 23:51
Pearl Pearl is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 05-09-03, 04:32
john67elco john67elco is offline
Registered User
 
Join Date: Apr 2003
Posts: 3
tahnk u both so much for your help. I am glad people are out there for help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On