What do you guys think of this? Its my first attempt at a useful C++ program. I would prefer to use if statements but I'm following a book and will learn it eventually. I might have used some time consuming code but I wanted to test my knowledge of functions.
Code:#include <iostream> float CircleArea(long int Radius, const float Pi); float CircleCircumference(long int Radius, const float Pi); /*Program created by ComDriver 13th Febuary 2005 This program can find a circle's area and circumference*/ int main() { long int MenuChoice, Radius, Diameter, Circumference; const float Pi = 3.141592653589793238462633832795; //Menu starts here std::cout << "Menu- Find a cicle's-\n\n"; std::cout << "1. Area\n"; std::cout << "2. Circumference\n"; //Menu ends here std::cout << "What would you like to do? "; std::cin >> MenuChoice; std::cin.ignore(80,'\n'); //The users Menu choice on what he wants to find is evaluated here if (MenuChoice == 1) { std::cout << "\nWhat is the radius of the circle (in centimetres): "; std::cin >> Radius; std::cin.ignore(80,'\n'); std::cout << "\nThe circle's area is: " << CircleArea(Radius, Pi) << " square cm."; } if (MenuChoice == 2) { std::cout << "\nWhat is he radius of the circle: "; std::cin >> Radius; std::cin.ignore(80,'\n'); std::cout << "\nThe circumference of the circle is: " << CircleCircumference(Radius, Pi) << "cm"; } std::cin.get(); return 0; } //This function finds a circles area float CircleArea(long int Radius, const float Pi) { return (Pi*Radius*Pi*Radius); } //This function finds a circles circumference float CircleCircumference(long int Radius, const float Pi) { return (2*Pi*Radius); }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.