|
|
C++ Programming |
|
|
Celsius to FahrenheitProgram 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
|
|
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
|
|
|
|
|