Đề bài:
XÂY DỰNG CHƯƠNG TRÌNH TÍNH ĐIỂM TRUNG BÌNH
Input: Nhập vào từ bàn phím điểm môn Toán, Lý, Hóa
Output: Hiển thị ra màn hình điểm trung bình
Biết rằng:
Hệ số của toán: x3
Hệ số của lý: x2
Hệ số của hóa: x1
#include
<stdio.h>
/* CHUONG TRINH
TINH DIEM TRUNG BINH*/
int main()
{
//Khai bao bien toan, ly, hoa
float toan, ly, hoa, diemTb;
// Thong bao va nhap cac diem cua toan,
ly, hoa
printf("Moi nhap diem mon toan:
");
scanf("%f", &toan);
printf("Moi nhap diem mon ly:
");
scanf("%f", &ly);
printf("Moi nhap diem mon hoa:
");
scanf("%f", &hoa);
/*
He so cua toan x3
He so cua ly x2
He so cua Hoa x1
*/
diemTb = (toan*3 + ly*2 + hoa)/6;
printf("=======================\n");
// Lam tron 1 chu so sau dau phay
printf("Diem trung binh cua ban la
%.1f", diemTb);
return 0;
}
Nhận xét
Đăng nhận xét