[r]
(1)Bài t p:ậ
Chương 1:
01:
#include<stdio.h> /* Hay so sanh tap tin exe voi BT01_03 */ main()
{
printf(" Chao ban !"); /* Co tap stdio.h */ printf("Moi ban lam quen voi Turbo C"); getch(); /* Dung man hinh de xem ket qua */ }
02
#include<stdio.h> #include<conio.h> main()
{
clrscr();
printf(" Chao ban !");
printf("Moi ban lam quen voi Turbo C"); getch();
}
03
#include<conio.h> /* Hay so sanh tap tin exe voi BT01_01 */ main()
{
clrscr(); /* Cau lenh xoa man hinh */
cprintf(" Chao ban !\n"); /* Co tap conio.h */ cprintf("Moi ban lam quen voi Turbo C");
getch(); }
04
#include<conio.h> main()
{
clrscr();
cprintf(" Chao ban !\n\r"); /* Them dinh dang \r de ve dau dong */ cprintf("Moi ban lam quen voi Turbo C");
getch(); }
(2)#include<stdio.h> main()
{
char ten[150];
printf("Cho biet ten cua ban \n"); scanf("%s",ten);
printf("Chao ban :%s\n",ten); getch();
}
06
#include<conio.h> main()
{
clrscr();
printf(" HOI THOAI VE TURBO C \n");
printf("-SON : Nghe noi hoc Turbo C kho lam phai khong ?\n");
printf("-HA : Cung nghe noi vay, nhung khong biet co dung khong ? \n"); printf("-XA : Thi cung tuong tu nhu Pascal vay thoi \n");
printf("-TAC : Ban da hoc roi phai khong, noi cho nghe di nao \n");
printf("-XA : Cung thuoc loai lap trinh cau truc nhung chay nhanh hon nhieu \n"); getch();
}
07
#include<conio.h> main()
{
clrscr();
cprintf(" AO THU \n\r"); cprintf("\n");
cprintf("Ao thu lanh leo nuoc veo\n\r"); cprintf("Mot chiec thuyen be teo teo\n\r"); cprintf("Song biec theo lan hoi gon ty\n\r"); cprintf("La vang truoc gio se dua veo\n\r"); cprintf("\n\r");
cprintf(" NGUYEN KHUYEN"); getch();
}
08
(3)int a,b,tong,hieu,tich; /*Khai bao bien so nguyen */ float thuong; /* Khai bao bien so thuc */
clrscr(); /* Lenh xoa man hinh */ printf("Nhap so thu nhat : ");
scanf("%d",&a); /* Lenh nhap so lieu tu ban phim va gan cho bien */ printf("Nhap so thu hai : ");
scanf("%d",&b); tong = a+b; hieu = a-b; tich= a*b;
thuong= (float)a/b; /* Chuyen doi kieu so nguyen sang so thuc */ printf("\n");
printf("Tong cua so a=%d va b=%d la=%d\n",a,b,tong); printf("Hieu cua so a=%d va b=%d la=%d\n",a,b,hieu); printf("Tich cua so a=%d va b=%d la=%d\n",a,b,tich); printf("Thuong cua so a=%d va b=%d la=%f\n",a,b,thuong); getch();
}
09
/* Chuong trinh Tinh chu vi va dien tich hinh tron */ #include "stdio.h"
main() {
float r,c,s;
printf("- Cho biet ban kinh r= "); scanf("%f",&r);
c=6.28*r; s=3.14*r*r;
/*In ket qua tren dong*/ clrscr();
printf(" KET QUA TINH CHU VI DIEN TICH HINH TRON \n"); printf(" -Ban kinh hinh tron r = %8.2f met \n",r);
printf(" -Chu vi hinh tron c = %8.2f met \n",c);
printf(" -Dien tich hinh tron s = %8.2f met vuong \n",s); getch();
}
10
/*Chuong trinh tinh x luy thua y*/ #include"stdio.h"
#include "math.h" main()
(4)double pow(); /*khai bao ham pow kieu double*/ double x,y,z; /* khai bao bien kieu double*/ clrscr();
printf("- Cho biet gia tri cua X= "); scanf("%lf",&x);
printf("- Cho biet gia tri cua Y= "); scanf("%lf",&y);
z=pow(x,y); /* Tinh x luy thua y va gan cho z */ /* In ket qua */
clrscr();
printf("KET QUA CUA CHUONG TRINH TINH X LUY THUA Y \n"); printf("- X= %8.2f \n",x);
printf("- Mu Y= %8.2f \n",y); printf("* X luy thua y = %8.2f",z); getch();
}
Chương 2
05:
main() {
clrscr();
printf("Truong Dai Hoc Tai Chanh Ke Toan"); printf("Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n -");
printf("Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n -");
printf("\n Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n Truong Dai Hoc Tai Chanh Ke Toan \n ");
printf("\n -");
printf("\n\t Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n -");
printf("\n\t\t Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n\t\t\r Truong Dai Hoc Tai Chanh Ke Toan \n "); printf("\n -");
printf("\n\t\t\r Truong \a Dai \a Hoc \a Tai \a" "Chanh \a Ke \a Toan \a ");
printf("\n\t\t\r Truong \a Dai \a Hoc \a Tai \a ", "Chanh \a Ke \a Toan \a ");
(5)06
/* Chuong trinh su dung cac ky tu dieu khien */ #include<stdio.h>
main() {
clrscr();
printf("\n Day la dau nhay don \'Turbo C 2.0 \'"); printf("\n");
printf("\n Va day la dau nhay kep \"Turbo C\" "); printf("\n");
printf("\n Duong dan vao file stdio.h la \"C:\\TC\\INCLUDE\\stdio.h\""); printf("\n\n File Edit Run Compile Project Debug Break/watch"); printf("\n EDIT \n\b COMPILE \n\b DEBUG \n\b WATCH "); printf("\n EDIT \a COMPILE \a DEBUG \a WATCH "); getch();
}
07
#include"stdio.h" main()
{
clrscr();
cprintf(" Day la nua tren dau tich phan : ma Ascii ," "he 16 la F4 \xF4 \n");
cprintf("\n\r\ Day la nua duoi dau tich phan : ma Ascii," "he 16 la F5 \xF5 \n");
cprintf("\n\r Day la ca dau tich phan "); cprintf("\n\r");
cprintf(" \xF4"); /*tao nguyen dau tich phan */ cprintf("\n\b\xF5");
getch(); }
08
#include"stdio.h" char c=97;
main() {
clrscr();
printf("\nc=%c\t c=%d",c,c); getch();
}
(6)printf("\n\nX=%4.1f Binh phuong =%6.1f Lap phuong =%7.1f",
x,binh_phuong(x),lap_phuong(x)); printf("\nSo lon nhat{x*x,x*x*x}=
%7.1f",lon_nhat(binh_phuong,lap_phuong,x));
printf("\n\nBam so de tiep tuc,so de dung "); scanf("%d",&c);
if (c==1) goto tt; }
#include<stdio.h> main()
{
int i;
tt:printf("\nCan tim nguoi thu may : "); scanf("%d",&i);
tim(i);
printf("\n\nBam so de tiep tuc,so de dung "); scanf("%d",&i);
if (i==1) goto tt; }
tim(ma) int ma;
{
static char *ds[]={"Sai ma roi","Nguyen Van Xuan", "Tran Van Ha","Bui Thi Thu","Pham Van Dong", "Chu Van Son","Dang Thi Ha","Le Van Xa","Vo Van Tac"};
printf("\n%10c Ma = ",'');
printf("%d Ten la : %s",ma,(ma<1 || ma >8) ? ds[0]:ds[ma]);
(7)