Mail Archives: djgpp/2001/02/27/13:18:38

From: "Brian Christiansen" <brianc23454 AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
References: <XoBm6.206$GF DOT 50463 AT sapphire DOT mtt DOT net>
Subject: Re: convert miles to kilometres
Lines: 31
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <aERm6.1175$>
Date: Tue, 27 Feb 2001 17:40:22 GMT
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: 983295622 (Tue, 27 Feb 2001 09:40:22 PST)
NNTP-Posting-Date: Tue, 27 Feb 2001 09:40:22 PST
Organization: EarthLink Inc. --
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Stewart" <jstewart1 AT ns DOT sympatico DOT ca> wrote in message
news:XoBm6.206$GF DOT 50463 AT sapphire DOT mtt DOT net...
> Can you help me write a C++ program that uses include <iostream.h> which
> a function to convert miles to kilometres.
Use #include <iostream> - this is the newer standard and if you have the
latest version of DJGPP, it certainly supports this form.

>( 1 km = 0.621371 miles I think)
> What const double can I use for the conversion factor?
0.621371 or its recipricol 1.6-whatever seems like a good idea to me.  If
you mean what name to use, any legal C++ name will do, though it is probably
better to use something that is "meaningful", like maybe "miles_to_km" (the
compiler itself doesn't care if you call it "fred".

> In more particular terms, I need help to write a program that prompts the
> user for a value in miles and outputs the equivalent value in km using a
> precision of 2 digits after the decimal.
To ouput other than the default number of decimal places, #include <iomanip>
and read up on the functions provided therein.

Can anyone help me?
I am sure there are plenty of people who can, probably even I could, but
since this sounds a whole lot like a homework assignment, attempt writing
this program, post the code, and I am sure that some nice peron will help
you fix it.

Brian Christiansen>

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019