C++ Programming

 

Celsius to Fahrenheit

Program to convert Celsius to Fahrenheit


Source Code

#include <iostream.h>
#include <iomanip.h>

// a program to convert Celsius to Fahrenheit
int main()
{

const int MAXCELSIUS = 50;
const int STARTVAL = 5;
const int STEPSIZE = 5;
int celsius;
float fahren;

cout << endl; // print a blank line
cout << "DEGREES DEGREES\n"
<< "CELSIUS FAHRENHEIT\n"
<< "------- ----------\n";

celsius = STARTVAL;

// set output formats for floating point numbers
cout << setiosflags(ios::showpoint)
<< setiosflags(ios::fixed)
<< setprecision(2);

while (celsius <= MAXCELSIUS)
{
fahren = (9.0/5.0) * celsius + 32.0;
cout << setw(4) << celsius
<< setw(13) << fahren << endl;
celsius = celsius + STEPSIZE;
}

return 0;
} 
 

 


DISCLAIMER

Paked and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.  (Disclaimer)

 

 

Home     Disclaimer     Advertise      Contact us     

Copyright © 2006-08 Paked.com. All rights reserved.

Note: Site best viewed at 1024 x 768 or higher screen resolution

 

footer image footer image