0% found this document useful (0 votes)
21 views9 pages

Bai Tap Lap Trinh - Nguyen Thi Kim Ngan 102240324

The document contains three C programming exercises. The first program determines the number of days in a month based on user input, the second solves a system of linear equations, and the third calculates a value based on user-provided inputs while handling specific conditions. Each program includes user prompts and conditional logic to manage different scenarios.

Uploaded by

Ngân Kim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views9 pages

Bai Tap Lap Trinh - Nguyen Thi Kim Ngan 102240324

The document contains three C programming exercises. The first program determines the number of days in a month based on user input, the second solves a system of linear equations, and the third calculates a value based on user-provided inputs while handling specific conditions. Each program includes user prompts and conditional logic to manage different scenarios.

Uploaded by

Ngân Kim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

BAI TAP 1:

#include <stdio.h>
#include <conio.h>
int main(){
int n;
printf("nhap vao so thang can tim: ");
scanf("%d", &n);
switch(n){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
printf("thang co 31 ngay");
break;
case 4: case 6: case 9: case 11:
printf("thang co 30 ngay");
break;
case 2:
printf("thang co 28 ngay neu nam khong nhuan, co 29
ngay neu la nam nhuan");
break;
default: printf("khong co thang do");
}
return 0;
}
BAI 3:
#include <stdio.h>
#include <conio.h>
int main(){
int a, b, c;
int m, n, e;
int x, y;
printf("nhap cac gia tri ham thu nhat vao:");
scanf("%d%d%d", &a, &b, &c);
printf("nhap cac gia tri ham thu hai vao:");
scanf("%d%d%d", &m, &n, &e);
int D, Dx, Dy;
D = a*n - b*m;
Dx = b*e - c*n;
Dy = a*e - c*m;
switch(D){
case 0:
if(Dx != 0 || Dy != 0){
printf("\nHe phuong trinh vo nghiem");
}
else if(Dx == 0 && Dy == 0){
printf("\nHe phuong trinh co vo so nghiem");
}
default:
x = Dx / D;
y = Dy / D;
printf("\nHe phuong trinh co nghiem la: x = %d va y = %d", x, y);
}
return 0;
}
BAI 2:
#include <stdio.h>
#include <conio.h>
int main(){
int x, a, b;
printf("nhap vao 2 so a,b: ");
scanf("%d%d", &a, &b);
lap:
switch(a){
case 0:
printf("nhap lai so a!");
scanf("\n%d", &a);
goto lap;
break;
default:
printf("x = %f", (float)-b/a);
}
return 0;
}

You might also like