Files

Inches to centimeters

The program below prints a table that converts inches to centimeters.

1
2
3
4
5
6
7
8
9
10
//Print table of inches to centimeters
#include <iostream>
using namespace std;
int main(void) {
   cout<<"INCHES\tCM\n"; //print heading
   for(int inches=1; inches<20; inches++)
     cout<<inches<<"\t"<<inches*2.54<<"\n";
   system("pause");
   return 0;
} //main
CODE

The output appears in the DOS window:
output of inches to cm

Unfortunately, we can't do anything else with it at this point.

Instead the next program writes the output to a file.

NEXT: Inches to Centimeters file