-
Notifications
You must be signed in to change notification settings - Fork 0
/
AREACIR3.C
62 lines (50 loc) · 1.58 KB
/
AREACIR3.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Jason J. Davis
COMP-335L
AAHS Summer '97
Sign off:____________________________ Row #:7
Date: ________________ Due:
AreaCir3.C --rewrite of a previous program (AreaCir2.C) with a loop
construct implimented.
*/
# include <stdio.h>
#include <math.h> /* Necessary for M_PI, and pow() */
#include <conio.h>
double getRadius (void);
double circArea (double calcRadius) ;
void displayResult (double outRadius, double outArea) ;
/* =============================================== */
void main (void)
{
double radius, area;
char continu;
do
{
clrscr();
radius = getRadius ();
area = circArea(radius);
clrscr();
displayResult (radius, area);
gotoxy(10,15);
printf("Do you whish to continue (n for no, any key to continue)? ");
continu = getche();
}while ((continu != 'N') && (continu != 'n'));
}
/*---------------------------------------------------------------------*/
double getRadius (void)
{
double inRadius;
printf("\n\nPlease enter the radius of your circle => ");
scanf("%lf", &inRadius);
return inRadius;
}
/*-------------------------------------------------------------*/
double circArea(double calcRadius)
{
return M_PI * pow(calcRadius,2); /* area =ărý */
}
/* ----------------------------------------------------------*/
void displayResult (double outRadius, double outArea)
{
printf("\n\n\n\nWith a radius of %0.3g units, ", outRadius);
printf("your circle has an area of %0.3g units\x0FD", outArea);
}