-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalc_C_S_of_Circle.cpp
More file actions
55 lines (53 loc) · 1.46 KB
/
Calc_C_S_of_Circle.cpp
File metadata and controls
55 lines (53 loc) · 1.46 KB
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
//Khai bao thu vien (Library)
#include <stdio.h>
#include<stdlib.h>
#include <math.h>
//Khai bao bien (Variable)
float r, c, s;
short int language;
//Khai bao hang (Const)
const float PI = 3.1415926;
int main()
{
printf("To start program, please select one of the following languages\n");
printf("1. English\n");
printf("2. Tieng Viet\n");
printf("Select your language to use: ");
scanf("%hd", &language);
system("clear");
//Main code
switch (language)
{
case 1:
{
//Input data
printf("Enter radius ");
scanf("%f", &r);
//The Circumference
c = 2*r*PI;
printf("The Circumference of circle with radius = %f is %.2f\n",r ,c);
//The Area
s = r*r*PI;
printf("The Area of circle with radius = %f is %.2f\n",r ,s);
break;
}
case 2:
{
//Nhap du lieu
printf("Xin hay nhap ban kinh ");
scanf("%f", &r);
//Tinh chu vi
c = 2*r*PI;
printf("Chu vi cua duong tron ban kinh = %.2f la %.2f\n",r ,c);
//Tinh dien tich
s = r*r*PI;
printf("Dien tich cua duong tron ban kinh = %.2f la %.2f\n",r ,s);
break;
}
default:
{
printf("failed to start, please try again. (error: invaid language selection)");
}
}
return 0;
}