Upcoming SlideShare
×

# แบบฝึกทักษะการเขียนโปรแกรมภาษาซีเล่ม2

5,860 views

Published on

2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
5,860
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
246
0
Likes
2
Embeds 0
No embeds

No notes for slide

### แบบฝึกทักษะการเขียนโปรแกรมภาษาซีเล่ม2

1. 1. F 2 F 1 F F2( ) F 4 F 10--------------------------------------------------------------------------------------------------------- F F1. n F . F 1 . F F F 1 F . F . F F F2. F F F F . %c . %d . %e . %f3. F F F F int m=5, n=8; printf( %d %dn , n,m); .01 .58 .53 .854. F F . float num value =2.2; printf( %f ,num value); . int extra = 30000; printf( e = %d ,extra); . float min = -0.5832; printf( %.2fn ,min); . int few = -30000; printf( f = %d ,few);5. F F F int c,k; double x,y,z; x=1.2; y=2.1; z= 3.2; c=3; z=x+y+z; k=z/c; printf( %f %f %f %d %f ,x,y,z,k,z/c);
2. 2. F 2 F 2 F F F . 1.20000 2.100000 3.200000 2 1.000000 . 1.20000 2.100000 6.500000 2 2.000000 . 1.20000 2.100000 6.500000 2 2.166667 . 1.20000 2.100000 3.200000 2 1.0666676. F F F . %x char . %f double . %.2f float . F F7. F F Run F F #include <stdio.h> #include <conio.h> void main() { clrscr(); printf(" TURBO C "); printf(" is easy programming. "); getch(); } . TURBO C . TURBO C is easy programming. . is easy programming. . TURBO C is easy programming8. F F float a,b; printf( input a= ); scanf(_____________ F 1_____________) printf( input b= ); scanf(_____________ F 2_____________) printf( a+b=%f ,a+b); F F F . F 1 %f ,&a F 2 %f ,&b . F 1 %f ,a F 2 %f ,&b . F 1 %f ,*a F 2 %f ,*b . F 1 %f ,a F 2 %f ,b
3. 3. F 2 F 39. F num int temp double F F F F F F F F F scanf( %lf %d ,___________); . num,temp . &temp, &num . temp, num . &num,&temp10. F F F F printf( %9s , HELLO ); . H E L L O . H E L L O . H E L L O . H E L L O
4. 4. F 2 F 4 F (Output) F F F F F library F F F printf() ,puts() ,putchar() F F F header file stdio.h F printf() F F F F F F F printf() printf ("format",variable); F F F F F F "" F F F2 F F F format F F F F F F F F F variable F F F F F F F printf() F % F F %c F F 1 (single character) %d F F (integer int ) 1 %e F (floating point ,float) e F 2.15e+2 F 215 %f , %lf F F float double %g F F float %h F short integer %o( ) F integer %x F integer %s F F %p F address F F
5. 5. F 2 F 5 F printf() ( F F ) a F b FF F 1 F (backspace) t F F F 1 ( horizontal) n F v F 1 r F " " ? ? F F printfprintf("Hello Program C"); F Hello Program Cprintf("ChalermKwan Stree school"); F ChalermKwan Stree schoolprintf("Phitsanuloke Thailand"); F Phitsanuloke Thailandprintf( 1+1 = %d ,2); F 1+1 = 2char x = x ; F Hello xyzprintf( Hello %cyz ,xint x = 3; 2 + 3 = fivechar y[5] = five ;printf( %d + %d = %s ,2,x,y 1. F F %d F F ( F 2) 2. F F %d F x F 3. F F %s F F y Fprintf( %dn ,233); 233printf( %05dn ,233); 00233printf( %fn ,233.33); 233.330000printf( %.2fn ,233.33); 233.33
6. 6. F 2 F 6 F F printf ( F ) printf( %8d ,245); 245 F F F5 F printf( %9s , Grass ); F Grass F F F4 F printf( %10c , z ); z F F F 9 F printf( %12f ,11.235); 11.235000 F F F6 F printf( %-8d ,245); 245 F F5 F printf( %-9s , Grass ); F Grass F F4 F printf( %-10c , z ); z F F 9 F printf( %-12f ,11.235); 11.235000 F F6 F putchar() ( char ) F F printf F %c F F F F putchar() F Fputchar(ch);ch : F c char
7. 7. F 2 F 7 F F putchar() F F puts() F F Fputs(str);str : F F F F F F puts() F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F scanf() F F F F F F scanf() F F F F F F FF ( int ) , ( float ) , ( char ) F F scanf() F F printf() F
8. 8. F 2 F 8 scanf( format , &variable) ; format : F F F F F F printf() variable : F F F F F F F F F F F F & F F F FF F F & F F scanf() F F F F getchar() getch() 2 F F ( char ) Fch = getchar();ch = getch();ch : char F F F
9. 9. F 2 F 9 FF getchar() getch() F F F 2 F F getchar() F F F <Enter> F F F F F F getch() FF <Enter> F F 1 F F F F F getchar() F F F F FF F <Enter> F F F getchar() getch() F F
10. 10. F 2 F 10 FF F getch() F F <Enter> F F gets() F F F F F F F F gets() F Fgets(str);str : F F F F F F FF Fgets()
11. 11. F 2 F 11F F gets() F F F F
12. 12. F 2 F 12 F F 1 (print1) F F F FHello C Language By Student F F- F F F F “Hello C Language By Student” ( F ) F 1 F F F F- Hello C Language By Student
13. 13. F 2 F 13 F F 2 (print2) F F F FWelcome to ProgrammingHello C Language F F- F F F F F “Welcome to Programming” ( F ) “Hello C Language” ( F ) F 1 F F F F- Welcome to Programming Hello C Language
14. 14. F 2 F 14 F F 3 (print3) F F F F num1 F F num1 F F 50 F F- F F F num1 F 1 F F F - 50
15. 15. F 2 F 15 F F 4 (print4) F F F F word1 F F word1 F B F F- F F F word F 1 F F F F- B
16. 16. F 2 F 16 F F 5 (print5) F F F F num1 F F F2 F F num1 F F 5.646555 F F- F F F num1 F 1 F F F F- 5.65
17. 17. F 2 F 17 F F 6 (print6) F F F F F F- F F char data[] = “basic operation” F 1 F F ba s i c o p e r a t i o n ba s i c b a s i c o p e r a t i o n
18. 18. F 2 F 18 F F F 1(scanf1) F F F F F 3 F num1 num2 num3 F FF F 3 1 F num1 2 F num2 2 F num3F F F F 1 F F3 3,4,545122 122,345,698345698
19. 19. F 2 F 19 F F F 2(scanf2) F F F F F F F F F F F 2 1 F weight 2 F high F F F F F 1 F FWeight : 45 Weight & High is 45,162High : 162Weight : 70 Weight & High is 70,165High : 165
20. 20. F 2 F 20 F F F 3(scanf3) F F F F F F F F F F F F F F F = F F * F F 4 1 F Id 2 F Name F 3 F Unit Price 4 F Quatity F F F F F F F F 1 F F F FEnter Product Id = B05 Id = B05Enter Product Name = NoteBook Name = NoteBookEnter Product Unit Price = 45 Unit Price = 45Enter Quatity = 3 Quatity = 3 Total Amount = 135.00
21. 21. F 2 F 21 F F F 4(scanf4) F F F F pi = 3.14 = 4/3*pi*radius*radius*radius( F 4/3 F = 1.33) F F 1 1 F F F F 1 F F F F5 522.025024 F 2 F F F F0.2 0.033410
22. 22. F 2 F 22 F F (average1) F F F 5 F F F F 2 1 F 1 2 F 2 3 F 3 4 F 4 5 F 5 F F F F 1 F F F F12 average = 1513141820 F 2 F F F F23 average = 2524282921
23. 23. F 2 F 23 F (area1)) F 2 F = F X F F 2 1 F F F 2 F F F F F 1 F F F F2 64 F 1 F F F F4 4010
24. 24. F 2 F 24 F (area2) 2(area2) F = 0.5 x XF F 2 1 F 2 FF F F 1 F F F F0.25 1.2500005 F 1 F F F F15 37.5000005
25. 25. F 2 F 25 F F 3(area3) F F F 2 F F F circumference = 2¶r¶ = 3.14 F F 1 1 F F F F F 1 F F F F12 75.36 F 1 F F F F.5 3.14
26. 26. F 2 F 26 F F (price) F F F F F 2 1 F 2 F 3 F F 4 F F 5 F 1 F F F FInput product id : b05 Id : b05Input product name : notebook Name : notebookInput product unit price : 45 Unit price : 45Input quantity : 3 Quantity : 3 Total amount : 135.00
27. 27. F 2 F 27 F2( ) F 4 F 10--------------------------------------------------------------------------------------------------------- F F1. n F . F 1 . F F F 1 F . F . F F F2. F F F F . %c . %d . %e . %f3. F F F F int m=5, n=8; printf( %d %dn , n,m); .01 .58 .53 .854. F F . float num value =2.2; printf( %f ,num value); . int extra = 30000; printf( e = %d ,extra); . float min = -0.5832; printf( %.2fn ,min); . int few = -30000; printf( f = %d ,few);5. F F F int c,k; double x,y,z; x=1.2; y=2.1; z= 3.2; c=3; z=x+y+z; k=z/c; printf( %f %f %f %d %f ,x,y,z,k,z/c);
28. 28. F 2 F 28 F F F . 1.20000 2.100000 3.200000 2 1.000000 . 1.20000 2.100000 6.500000 2 2.000000 . 1.20000 2.100000 6.500000 2 2.166667 . 1.20000 2.100000 3.200000 2 1.0666676. F F F . %x char . %f double . %.2f float . F F7. F F Run F F #include <stdio.h> #include <conio.h> void main() { clrscr(); printf(" TURBO C "); printf(" is easy programming. "); getch(); } . TURBO C . TURBO C is easy programming. . is easy programming. . TURBO C is easy programming8. F F float a,b; printf( input a= ); scanf(_____________ F 1_____________) printf( input b= ); scanf(_____________ F 2_____________) printf( a+b=%f ,a+b); F F F . F 1 %f ,&a F 2 %f ,&b . F 1 %f ,a F 2 %f ,&b . F 1 %f ,*a F 2 %f ,*b . F 1 %f ,a F 2 %f ,b
29. 29. F 2 F 299. F num int temp double F F F F F F F F F scanf( %lf %d ,___________); . num,temp . &temp, &num . temp, num . &num,&temp10. F F F F printf( %9s , HELLO ); . H E L L O . H E L L O . H E L L O . H E L L O
30. 30. F 2 F 30
31. 31. F 2 F 31 F F 1 F30250 F 2( ) F 4 F 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
32. 32. F 2 F 32 F F 1 (print1) # include <stdio.h> # include <conio.h> int main () { printf("Hello C Languade By Student") ; getch() ; } F 2 (print2)# include <stdio.h># include <conio.h>int main (){ printf("Welcome to Programn") ; printf("Hello C Languade"); getch() ;} F 3 (print3) # include <stdio.h> # include <conio.h> int main () { int num1 ; num1 =50; printf("%d",num1); getch() ; } F 4 (print4) # include <stdio.h> # include <conio.h> int main () { char word1; word1=B; printf("%C",word1); getch (); }
33. 33. F 2 F 33 F 5 (print5) # include <stdio.h> # include <conio.h> int main () { float num1 ; num1= 5.646555 ; printf ("%.2f",num1) ; getch () ; } F 6 (print6)#include <conio.h>#include <stdio.h>int main(){ char data[]="basic opertion"; printf("%sn",data); printf("%.5sn",data); printf("%23s",data); getch();} F F 1(scanf1) # include <stdio.h> # include <conio.h> int main () { int num1 ,num2,num3; scanf(“%d”,&num1); scanf(“%d”,&num2); scanf(“%d”,&num3); printf ("%d , %d , %d ",num1.num2,num3) ; getch () ; }
34. 34. F 2 F 34 F F 2(scanf2) # include <stdio.h> # include <conio.h> int main () { int weight ,high; printf(“weight “); scanf(“%d”,&weight); printf(“height “); scanf(“%d”,&high); printf (“weight & high is %d , %d ", weight ,high) ; getch () ; } F F 3(scanf3)#include <stdio.h>main(){ char ID[10],name[20]; float price; int quantity; printf("Enter Product ID : "); scanf("%s",ID); printf("Enter Product Name : "); scanf("%s",name); printf("Enter Product Unit Price : "); scanf("%f",&price); printf("Enter Quantity : "); scanf("%d",&quantity); system("cls"); printf("ID:%s”,ID); printf(Name:%s”,name); printf( Unit Price:%.2f”,price); printf( Quantity:%d”,quatity); printf( Total Amount:%.2f",price*quantity); getch();}
35. 35. F 2 F 35 F F 4(scanf4) # include <stdio.h> # include <conio.h> int main () { float radius ,c,pi=3.14; scanf("%f",&radius) ; c=1.33*pi*radius*radius*radius; printf("%f",c) ; getch () ; } F (average1) # include <stdio.h> # include <conio.h> int main () { int f,s,t,p,a,c; scanf("%d",&f) ; scanf("%d",&s) ; scanf("%d",&t) ; scanf("%d",&p) ; scanf("%d",&a) ; c=(f+s+t+p+a)/5; printf("%d",c) ; getch () ; } (area1))# include <stdio.h> # include <conio.h> int main () { int weight,high ; scanf("%d",&weight) ; scanf("%d",&high) ; printf("weight & high is %d",weight,high) ; getch () ; }
36. 36. F 2 F 36 (area2) 2(area2)# include <stdio.h> # include <conio.h> int main () { float b,h,t; scanf("%f",&b) ; scanf("%f",&h); t=0.5*b*h; printf("%f",t) ; getch () ; } F 3(area3)# include <stdio.h># include <conio.h>int main (){ float radius ,c,pi=3.14; scanf("%f",&radius) ; c=2*pi*radius; printf("%.2f",c) ; getch () ; }
37. 37. F 2 F 37 F (price)#include <conio.h>#include <stdio.h>int main(){ char id[10],name[20]; float price; int quantity; float total; printf("Input product id : "); scanf("%s",&id); printf("Input product name :" ); scanf("%s",&name); printf("Input product unit price : "); scanf("%f",&price); printf("Input quantity : "); scanf("%d",&quantity); printf("id : %sn",id); printf("name : %sn",name); printf("quantity : %dn",quantity); printf("price : %.2fn",price); printf("toatal amount : %.2f",quantity*price); getch();}
38. 38. F 2 F 38 F 2 F30250 F 2( ) F 4 F 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
39. 39. F 2 F 39.................................................. ................... .............................................. ................................................................................................................................. F F 10 10 F 15 15 ........................................... ( F )
40. 40. F 2 F 40 F F .(2547). F F . F 1. F F . F .(2545). .F F 1. : F ( - ). F .F (2549). F F . F 1. : F F . F F .F (2550). F F . F 1. : ( ). .(2547). F . : . Fhttp://e-learning.snru.ac.th/els/program1/lesson3/page3_1.htmlhttp://e-learning.snru.ac.th/els/program1/lesson3/page3_1.htmlhttp://www.thaigoodview.com/library/contest2551/tech02/08/2/webit/p3.htmlhttp://www.rayongwit.ac.th/data_math/kind.htmhttp://thaioop.wordpress.com/http://www.plaloma3d.com/webboard/viewthread.php?tid=685http://www.skr.ac.th/~pasakorn/c/lesson/l33.html#vahttp://www.programming.in.th/tutorial/index.phphttp://www.sangsiri.net/wbi/40208_sci/http://www.eng.su.ac.th/ee/618240/variable.htmlhttp://www.eng.su.ac.th/ee/618240/variable.htmlhttp://www.lks.ac.th/kuanjit/http://www.rayongwit.ac.th/data_math/kind.htmhttp://web.en.rmutt.ac.th/computerprogramming/Documents/Presentation/PDF/C.pdf
41. 41. F 2 F 41
42. 42. F 2 F 42 30250 F2 ( ) F F F 4 F 2 F F F F F F F F F F F F F F F2( ) F F F F FF 4 F F F F
43. 43. F 2 F 43 F F F F F F 1 F 4 (output) 4 F printf() 4 putchar() 6 puts() 7F F F 7 scanf() 7 getchar() getch() 8 12 27 30 F 24 40
44. 44. F 2 F 44 F F 2 F F F F F F F2 ( F ) 30250 F F F F 1. F F F 2. F F F F F F F F F 3. F Download F http://Arnon.chs.ac.th F 4. F F F F F 5. F F F 6. F F F F F F 7. F F F F 8. F 9. F F F F 10. FF 11. F F F F FF F F F
45. 45. F 2 F 45 F F 2 F F F F F F F F F F F FF F 1. F F FF 2. F F F F F F F 3. FF F F F 4. F F F F
46. 46. F 2 F 46 F F F F F F F F FF F F F F F F F 1. F F F F 2. F F F F 3. F F F F F F 4. F F F F F F