|
פתרון/* Module: tr2_q3.cpp Author: Yariv Amar What? This program calculates S and P for any given radius of a circle. Input : Radius of circle Output: P & S of the circle Assumptions on input: Non negativ number. How? Algorithm : trivial P=2*PI*R S=PI*R*R */ # include <iostream.h> void main() { const double PI=3.141592654; //define PI as a constant variable double Radius ; cout << "Please enter the radius of the circle :"; cin >> Radius; // Get radius from the user cout <<"=======================================\n"; // The next 2 lines will calculate and print S & P cout <<"The S (area) of the circle is: "<<PI*Radius*Radius<<"\n"; cout <<"The P (length) of the circle is: "<<2*PI*Radius<<"\n"; } פלטים מיצגיםפלט לדוגמה:
|
© Copyright YAProductions 2000 |