c circle area

Solutions on MaxInterview for c circle area by the best coders in the world

showing results for - "c circle area"
Lucia
20 May 2017
1#include <stdlib.h>
2#include <stdio.h>
3#include <math.h>
4
5#define P 3.1415926535
6
7int main() {
8	int a, c;
9	double b;
10	
11	printf("AREA OF A CIRCLE\n\n\n1: Direct formula\n2: Invers formula\n\nChose: ");
12	scanf("%d", &c);
13	
14	switch (c)
15	{
16		case 1:
17			printf("\nEnter radius value: ");
18			scanf("%d", &a);
19			
20			b = a * a * P;
21			
22			printf("\nArea: %f\n\n", b);
23			
24			break;
25			
26		case 2:
27			printf("\nEnter area value: ");
28			scanf("%d", &a);
29			
30			b = sqrt(a / P);
31			
32			printf("\nRadius: %f\n\n", b);
33			
34			break;
35	}
36	
37	if(c != 1 && c != 2)
38	{
39		printf("The value is not accepted\n\n");
40	}
41
42	system("pause");
43}