Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple Temperature Program
Index -> Programming, C++ -> C++ Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kingnoz




PostPosted: Tue Sep 02, 2003 1:07 pm   Post subject: Simple Temperature Program

this is a simple temperature program i did using VC++ under win32 console application...it is simple but incorporates many things like user-defined functions, cin, cout, declaring integers.

the code is commented on to help ppl understand

code:

// temperature.cpp - converts Celsius to Fahrenheit
#include <iostream>
using namespace std;

int Celsius;        //declares Celsius
int Fahrenheit;  //declares Fahrenheit

void temp(int);   // function prototype for temp()
int main()
{
        cout << "Please enter a Celsius value: ";              //displays the question in ("") on the screen
        cin >> Celsius;  // asks the user for the integer Celsius
        temp(Celsius);    //calls the temp function
        return 0;
}

void temp(int Celsius)  //the void is used to say that temp has no return value
{
        Fahrenheit = Celsius * 1.8 + 32.0;      //formula to change Celsius to Fahrenheit
        cout << "The temperature " << Celsius <<
        " degrees Celsius is equal to " << Fahrenheit << " degrees Fahrenheit.\n";      //displays the Celsius then the equivalent Fahrenheit
}
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: