-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab4b81.c
More file actions
43 lines (40 loc) · 1 KB
/
lab4b81.c
File metadata and controls
43 lines (40 loc) · 1 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
#include<stdio.h>
int main(){
double a,b;
char c;
printf("Nhap so thu nhat:");
scanf("%lf", &a);
printf("Nhap so thu hai:");
scanf("%lf", &b);
printf("MENU\n");
printf("======================\n");
printf("+.\n");
printf("-.\n");
printf("x.\n");
printf(":.\n");
printf("Chon phep tinh (+, -, x, :): ");
//getchar();
scanf(" %c", &c);
switch(c) {
case '+':
printf("%.2lf + %.2lf = %.2lf \n", a, b, a+b);
break;
case '-':
printf("%.2lf - %.2lf = %.2lf \n", a, b, a-b);
break;
case 'x':
printf("%.2lf x %.2lf = %.2lf \n", a, b, a*b);
break;
case ':':
if(b != 0){
printf("%.2lf : %.2lf = %.2lf \n", a, b, a/b);
}else {
printf("Khong co phep chia cho so 0\n");
}
break;
default:
{ printf("Nhap lai dau thich hop\n");}
break;
}
return 0;
}