/* ************************************************************************** * Program name : 006_Area_of_Circle (Version 1.00) * * Author : Duck Wong * * Language : C / C++ * * Compiler : Boodshed Dec-C++ compiler Ver 3.95 * * Computer : PII350 * * O/S : Windows 98 * ************************************************************************** * Version 1.00 : 2000/06/04 - first version * ************************************************************************** * Description : (a) intut the radius of a circle * * (b) calculate the area, diameter and circumference * * (c) output results * ************************************************************************** */ #include #include int main() { // Part 1 : declaration const float pi = 3.14159; // Note (1) float radius, area, diameter, circumference; char again = 'Y'; // Note (2) while (again=='Y'||again=='y') // Note (3) & (4) { // Part 2 : input cout << "\nPlease input the radius of the circle : "; cin >> radius; // Part 3 : calculation diameter = 2*radius; area = radius*radius*pi; circumference = diameter*pi; // Part 4 : output cout << "\nThe diameter is : " << diameter << "\nThe area is : " << area << "\nThe circumference is : " << circumference << "\n" << endl; // Part 5 : run this program again cout << "\n\a Try again (Y/N) : "; cin >> again; }; //End of while loop system("PAUSE"); return 0; } /* Notes (1) const float pi=3.14159; => CONST pi=3.14159; (in Pascal) float pi = 3.14159 means set the value of 3.14159 to identifier pi (2) char again = 'Y' means set the value of 'Y' to identifier 'again' (3) (again=='Y'||again=='y') = ((again='Y')or(again='y')) in Pascal (4) Unlike Pascal, the while loop statement in C++ does not use 'DO'. */