Important alert: (current site time 7/15/2013 6:48:09 PM EDT)
 

VB icon

Simple Hello-World Type C++ Console Temp. Conv.

Email
Submitted on: 12/25/1999
By: Jeff Katz  
Level: Beginner
User Rating: By 5 Users
Compatibility: C++ (general)
Views: 26736
 
     Converts Either Fahrenheit to Calcius or Calcius to Fahrenheit, Good For Beginners. | If You Like It, Vote Highly For It!
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Simple Hello-World Type C++ Console Temp. Conv.
//**************************************
iostream.h, conio.h
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Simple Hello-World Type C++ Console Temp. Conv.
// Description:Converts Either Fahrenheit to Calcius or Calcius to Fahrenheit, Good For Beginners. | If You Like It, Vote Highly For It!
// By: Jeff Katz
//
// Assumes:Must be a console application
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=259&lngWId=3//for details.//**************************************

#include <iostream.h>
#include <conio.h>
double ctof(double x);
double ftoc(double x);
void ftocf();
void ender();
void ctoff();
int op;
void main ()
{
op=0;
cout<<"Select an Option:"<<endl;
cout<<" 1 for F to C"<<endl;
cout<<" 2 for C to F"<<endl;
cout<<" 3 To End"<<endl;
cin>>op;
if(op==1) ftocf();
if(op==2) ctoff();
if(op==3) ender();
}
void ctoff()
{
int x;
cout<<"Enter Degrees Celcius to Make Into Fahrenheit:"<<endl;
cin>>x;
cout<<"Result: "<<ctof(x)<<endl<<endl;
main();
}
void ftocf()
{
int y;
cout<<"Enter Degrees Fahrenheit to Make Into Celcius:"<<endl;
cin>>y;
cout<<"Result: "<<ftoc(y)<<endl<<endl;
main();
}
double ctof(double x)
{
	return ((x*1.8)+32);
}
double ftoc(double y)
{
	return ((y-32)/1.8);
}
void ender()
{
	cout<<"Press Any Key to Exit"<<endl;
	getch();
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

11/4/2003 1:17:33 PMvivek patel

if u vote for this code.......than u will really enjoy my code...logon to http://www.vivekpatel.cjb.net
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.