OT: C++ Question, solved

Karl F. Larsen klarsen1 at gmail.com
Fri Mar 13 17:14:42 UTC 2009


Ray Leventhal wrote:
>>    I will try to do that but the darn mail system seems to screw up 
>> other parts. I am thinking perhaps a source code should be sent as a 
>> file attached to the message. Can you do that. I will try...I have 
>> attached "ex78.cc" so see if you can play with that. It works :-)
>>
>> Karl
>>
>>     
> It is common on other lists to use the pastebin[1] service for inclusion 
> of source code and other data such as long config files, etc.
>
> Just my .02.
>
> -Ray
>
> [1] http://pastebin.com/
>
>
>   
//*********************************************************************
//  Program Convert: this program converts feet and inches to centimeters
// using 1 inch = 2.54 CM.
//***********************************************************************

#include <iostream>
using namespace std;

//    Named constants
const double conversion = 2.54;
const int inchesPerFoot = 12;

int main()
{
//   declare variables
   int feet;
   int inches;
   int totalInches;
   double centimeter;

//      Statements: Step 1 - Step 7
   cout<<"Enter two integers, one for feet, "
   <<" one for inches: ";                                 //Step1
   cin>>feet>>inches;                                    //Step2
   cout<<endl;
   cout<<" The numbers you entered are "<<feet
   <<" for feet   "<<"and " <<inches
   <<" for inches. "<<endl;                                //Step3
  
   totalInches = inchesPerFoot * feet + inches;           //Step4
   cout<<endl;
   cout<<" The total number of inches = "
       <<totalInches<<endl;                               //Step5
   centimeter = conversion * totalInches;                 //Step6
   cout<<" The number of centimeters = "
   <<centimeter<<endl;                                   //Step7
   return 0;
   }
  
  
   OK this I did with putting the source code on the text editor and 
then select all and then copy and then paste w/o format.

Karl


-- 

	Karl F. Larsen, AKA K5DI
	Linux User
	#450462   http://counter.li.org.
   PGP 4208 4D6E 595F 22B9 FF1C  ECB6 4A3C 2C54 FE23 53A7





More information about the ubuntu-users mailing list