Categories

Fahrenheit to celsius example

#include

int main()
{
double fahr , celsius;
coutfahr;
//convert to celsius
celsius = (5.0 / 9.0) * (fahr – 32.0);
cout

A setw example

//illustrates setting cout width

#include
#include
#include

int main()
{

cout

Another file example

#include
#include

int main()

{
// first lets output to a file
ofstream fout(“sample.txt”);
fout str;
fin.close();
//display sample.txt contents
cout

A file example

#include
#include
const char *FILENAME = “myfile.txt”;

int main()
{
//create output object associated w/ file
ofstream fout(FILENAME);
cout > str;
//write the text to the file
fout

A cout.width example

//illustrates setting the minimum
//output width using the width member
#include
#include

int main()
{
int i;
for(i=0;i