/***************************************************** * This program caculates the absolute stellar * * based on relative magintude and distance * * -------------------------------------------------- * * SAMPLE RUN: * * * * To calculate absolute stellar magnitude: * * Give relative mag. and distance in parsecs: 10 3 * * * * A star with relative magnitude 10.00 * * at a distance of 3.0 parsecs * * has an absolute magnitude of 12.61 * * * * -------------------------------------------------- * * Ref.: "Problem Solving with Fortran 90 By David R. * * Brooks, Springer-Verlag New York, 1997". * * * * C++ Release By J-P Moreau, Paris. * * (www.jpmoreau.fr) * ****************************************************** ! Explanations; ! ------------ ! The absolute magnitude M of a star is related to its ! relative magnitude m and and the distance to a star r, ! measured in parsecs, where 1 parsec = 3.26 light years, ! by the equation: ! ! M = m + 5 - 5 log10(r) ! ! According to this equation, a star with a relative ! magnitude of +1 at a distance of 10 parsecs has an ! absolute magnitude of +1. The larger the magnitude, the ! dimmer the star. Sirius is a very bright star with a ! relative magnitude of -1.58. Stars visible to the naked ! eye range mostly from about +1 to +6 in relative magni- ! tude. ! The dimmest star that can be seen with the 200-inch ! Hale telescope has a magnitude of about +23. !-------------------------------------------------------*/ #include #include void main() { double abs_mag, rel_mag, parsecs; printf("\n To calculate absolute stellar magnitude:\n"); printf(" Give relative mag. and distance in parsecs: "); scanf(" %lf %lf", &rel_mag, &parsecs); abs_mag = rel_mag + 5.0 - 5.0 * log10(parsecs); printf("\n A star with relative magnitude %6.2f\n", rel_mag); printf(" at a distance of %5.1f parsecs\n", parsecs); printf(" has an absolute magnitude of %6.2f\n\n", abs_mag); } // end of file starmag.cpp