-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab4b2.c
More file actions
28 lines (27 loc) · 729 Bytes
/
Copy pathlab4b2.c
File metadata and controls
28 lines (27 loc) · 729 Bytes
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
#include<stdio.h>
#include<math.h>
int main(){
float a, b, c;
float delta, x1, x2;
printf("nhap he so a:");
scanf("%f", &a);
printf("nhap he so b:");
scanf("%f", &b);
printf("nhap he so c:");
scanf("%f",&c);
delta = b * b - 4 * a * c;
if (delta > 0) {
x1 = (-b + sqrt(delta)) / (2 * a);
x2 = (-b - sqrt(delta)) / (2 * a);
printf("Phuong trinh co 2 nghiem phan biet:\n");
printf("x1 = %f\n", x1);
printf("x2 = %f\n", x2);
} else if (delta == 0) {
x1 = -b / (2 * a);
printf("Phuong trinh co nghiem kep:\n");
printf("x = %f\n", x1);
} else {
printf("Phuong trinh vo nghiem\n");
}
return 0;
}