Professional Documents
Culture Documents
Demo - Lab 3
Demo - Lab 3
int main() {
// Khai cac tham so x, y
double x, y;
printf("Nhap x, y: ");
scanf_s("%lf %lf", &x, &y);
if (x != 0)
// Goi ham giai phuong trinh bac nhat: GPTBN(x,y);
printf("No of PT: %.2lf", GPTBN(x, y));
else
GPTBN(x, y);
_getch();
return 0;
}
// case 1: a!=0
if (a != 0)
x = -b / a;
else {
if (b == 0)
printf("PT co VSN\n");
else {
printf("PT VN\n");
exit(1);
}
}
return x;
}
---------------------------------------------------
• Lớp khác: Cấu trúc IF-ELSE
Bài toán
Viết hàm xếp loại trung bình
------------------------------------
Demo
-------------------------------------------
/***********************************************
* Viet ham giai Phuong trinh bac nhat
* ax + b = 0;
************************************************/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main() {
/*------- Testing Ham XepLoai() --------*/
double avg = 0;
printf("Nhap dtb: ");
scanf_s("%lf", &avg);
// Goi ham XepLoai()
XepLoai(avg);
_getch();
return 0;
}
// Testing
/*Nhap dtb: 7.8
Xep loai kha
-------------------------------------------------------------------