|
|
|
|
Celsius to FahrenheitBinary Search | Bubble Sort | Selection Sort | Finding Maximum Value | Linear Search | Celsius to Fahrenheit | 10 Pseudo-random numbers | Calculating Average | Swapping Values | Lowercase/ Uppercase Program to convert Celsius to Fahrenheit C++ 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;
}
Copyrights Gary Bronson. "A First Book of C++: From Here to There " Thomson Learning. |
|
|
|