--33
C
8-11
--       18Mind Map         19-   -        -
(array)     array                                    index)     1.           1       one dimension arrays         singledi...
Type arrayname[size];        type                                int char float        arrayname                          ...
int                                                     a[]={200,230};                    a             array          int...
4                                           4       5       20   num[ ]                  2.00      num[3]                5...
char                                          1array          char                        12        x    1      12bytes   ...
array         x[6]                                            array       array                                        x  ...
table[0][0]                                                       array                     type arrayname [r] [c];       ...
r,c,p     array      p       0,1,2 .. , p-1      r       0,1,2, … ,r-1      c       0,1,2 … ,c-1                          ...
array of arrays                                                   array           table[3][4][5]table[0][0][0]      table[...
type arrayname[ ]…[ ]                               array                                   type arraynamearray5_1.c      ...
sum = 0;    for (i=0;(i+1)<=time;i++)    {        printf(”Please type the floating number for %d round:”,i+1);        scan...
char name[5][20] ={ “Chattam Sermsub”,”SompolSomsuk”,”Kanokporn                       Kanok”,             “ApinyaSittipa”,...
1.                                            forfor (n =   ; n <=    ; n++){printf ( “ Score = “ ) ;scanf ( “ %d “ , &sco...
nfor (n = ; n <         ; n++){}for (m =       ; m <=     ; m++){printf ( “ Score = “ ) ;scanf ( “ %d “ , &score [ n ] [ m...
type array_name [ n ] [ r ] [ c ] = { value list } ;          type                              int, float, char          ...
for (n =   ; n <=    ; n++){printf ( “ Score = %d n” , score [ n ] ) ;}                                                   ...
printf (“ %d  t  t “ , num );    }                                       (Strings)                           String consta...
2           char arrayname[r][c];           char          arrayname[r][c]      =       {”stringconstants0″,”string constan...
{     clrscr();     char name[50][50],changwad[50][30] ; int time,i,j;     printf(”Enter      number            of        ...
strlen1.c                              strlen()/* strlen1.c */#include <stdio.h>#include <conio.h>#include <string.h>char ...
1                             2                          1                           1                             2      ...
{printf(”Your strings = Program strings. compareresultis %d”,compareresult);}      else      {printf(”Your strings > Progr...
strcpy(word ,word ;      printf(”n st      strings   are         :%s       nd   strings   are:%s”,word ,word ;}           ...
char, int, long,float, double, unsigned int, unsigned long int,       •                            2              1.      ...
3.  long                                                    2                                                          lon...
3.4E-38           3.4E+38Float           32                                            6                                  ...
15 printf(“Area = %f”,area);               16 printf(“%f”,radius); }          2 int a ;                                   ...
char key = ?A?; /*     keycharacter    ?A? */    char name = ?SAM? /*         namecharacter   ”SAM” */
“             ”     “       ”     type        array        float          salary3.             float     float           d...
arraychardouble
http://courseware.bodin.ac.th/computer/AdvancedLevel4/programming/C_language/5.htm    http://www.no-poor.com/CandDelphi/ch...
รายงานคอม
Upcoming SlideShare
Loading in...5
×

รายงานคอม

97

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
97
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "รายงานคอม"

  1. 1. --33
  2. 2. C
  3. 3. 8-11
  4. 4. -- 18Mind Map 19- - -
  5. 5. (array) array index) 1. 1 one dimension arrays singledimensionarrays) word[20] ,num[25] , x[15] 2. multi-dimension arrays 2.1 2 2 a[3][5] , name[5][6] 2.2 3 3 a[3][5][6] , name[5][6][8]
  6. 6. Type arrayname[size]; type int char float arrayname array size int a[12]; array a arrayinteger a[0] a[1] a[2] a[3] …a[11] arrayinteger array array int num1[3]={56,25,89}; num1 array integer num1[0]=56; num1[1]=25; num1[2]=89;
  7. 7. int a[]={200,230}; a array integer a[0] 200 a[1] 230 int value[ ]; {} , int a[ ]={200,230}; intmoney[5]; money[0] = 250; money[4] = 500; float num[5]; array float num num[0] num[1]…num[4] array
  8. 8. 4 4 5 20 num[ ] 2.00 num[3] 55.52 num[1] ,num[2] num[4] array float array integer {} , Float num[5] ={2.00,1.25,5.36,6.32,246.10}; num[0] =2.00 num[1] = 1.25 num[2] =5.36 num[3] = 6.32 num[4] = 246.10 float salary[10]; salary[0] = 25000.00; salary[9] = 55600.00; chara[12]; array a array char 2 a[0] a[1] …a[11]
  9. 9. char 1array char 12 x 1 12bytes array stringvariable) integer float 2 two dimensionarrays) array 2 row) column)
  10. 10. array x[6] array array x array 2 array array array array table[0]table[1] table[2] array table array table array table[0][0] , table[0][1]… table[2][3]
  11. 11. table[0][0] array type arrayname [r] [c]; type int , float ,char arrayname array num , word ,x r,c r 0,1,2… , r-1 c 0,1,2 … , c-1 intnum[3][4]; array integer num[0][0],num[0][1] ,num[0][2],num[0][3],num[1][0],…,num[2][3] char word[ ][ ] ={“Bodin”,”decha”,”Computer”,”Pentium”};word array x9 word[0] = “Bodin” word[1] = “dehca” word[2] =“Computer” word[3] = “Pentium“ int num[2][2]; num[0][1]=3; array 3 type arrayname[p] [r][c]; type int ,float,char arrayname
  12. 12. r,c,p array p 0,1,2 .. , p-1 r 0,1,2, … ,r-1 c 0,1,2 … ,c-1 array arrays ofarrays array 3 table[3][5][4] table[5][4][3]
  13. 13. array of arrays array table[3][4][5]table[0][0][0] table[0][0][0] table[0][0]table[0][0] table[0][4] table[0] table[0] table[2] table table[3[[5][4] array r *c*p array array array array array array
  14. 14. type arrayname[ ]…[ ] array type arraynamearray5_1.c array/* array5_1.c */#include <stdio.h>#include <conio.h>main(){ clrscr(); float num[50]; float sum; int i,time; printf(”n Enter the time of input that you want. :”); scanf(”%d”,&time);
  15. 15. sum = 0; for (i=0;(i+1)<=time;i++) { printf(”Please type the floating number for %d round:”,i+1); scanf(”%f”,&num[i]); sum = sum + num[i]; } printf(”n Input = %d time sum.of them =%4.2f average of data is%4.2f”, time , sum , sum/time) ;}array5_2.c array/* array5_2.c */#include <stdio.h>#include <conio.h>main(){ clrscr(); float num[5][4] ;
  16. 16. char name[5][20] ={ “Chattam Sermsub”,”SompolSomsuk”,”Kanokporn Kanok”, “ApinyaSittipa”,”Wimolsiri Sirimol”}; int time,i,j; num[0][0] = 1.0; num[0][1] = 1.5; num[0][2] = 2.0;num[0][3] = 2.5; num[1][0] = 1.5; num[1][1] = 2.0;num[1][2] = 2.5; num[1][3] = 3.0; num[2][0] = 1.0; num[2][1] = 1.5; num[2][2] =2.0; num[2][3] = 2.5; num[3][0]= 1.5; num[3][1] = 2.0; num[3][2] =2.5; num[3][3] = 3.0; num[4][0]= 1.5; num[4][1] = 2.0; num[4][2] =2.5; num[4][3] = 3.0; printf(”Enter number of Student :”); scanf(”%d”,&time); for (i=0;(i+1)<=time;i=i+1){ printf(”n Student no. %d is %s t hasnum.”,i+1,name[i]); for (j=0;(j+1)<=4;j++) printf(”, %4.2f “,num[i][j]); }}
  17. 17. 1. forfor (n = ; n <= ; n++){printf ( “ Score = “ ) ;scanf ( “ %d “ , &score [ n ] ) ;} score scanf
  18. 18. nfor (n = ; n < ; n++){}for (m = ; m <= ; m++){printf ( “ Score = “ ) ;scanf ( “ %d “ , &score [ n ] [ m] ) ;} for 2. type array_name [ size] = { value list } ; type array_name [ r ] [ c ] = { value list } ;
  19. 19. type array_name [ n ] [ r ] [ c ] = { value list } ; type int, float, char array_name size value list , n] r] c] , , , ,a[ =a[ =a[ =a[ =a[ =int a [ { , , , , }; 3.printf (“ %d” , a[ ;
  20. 20. for (n = ; n <= ; n++){printf ( “ Score = %d n” , score [ n ] ) ;} score printf “ Score = %d n” , score [ n]); nfor (n = ;n< ; n++){}for (m = ; m < ; m++){}for (p = ; p < ; p++){num = score [ n ] [m] [p] ;
  21. 21. printf (“ %d t t “ , num ); } (Strings) String constants) “” “ Computer ” , “ TAMMANOON ” “ mile ”, “ 123456 ” (String variables) array) char char word[3] = “Ok”; char speech[2][20] ={”Hello”,Thailand”}; null character(0) 1 char arrayname[c]; char arrayname[c] = “string constants”; arrayname c string constants
  22. 22. 2 char arrayname[r][c]; char arrayname[r][c] = {”stringconstants0″,”string constants1,…,”string constants(r-1)}; arrayname r c string constants r-1r c- assignment(=) arrayname[2][10] ={”Bodin”,”12345d,”food}; for , while ,do whilearray5_3.c/* array5_3.c */#include <stdio.h>#include <conio.h>main()
  23. 23. { clrscr(); char name[50][50],changwad[50][30] ; int time,i,j; printf(”Enter number of Student :”);scanf(”%d”,&time); i =0; while (i<=(time-1)) { printf(”n Enter name of %dth person :”,i+1); scanf(”%s”,name[i]); printf(”n Enter changwad of %dth person :”,i+1); scanf(”%s”,changwad[i]); i++; } for (j=0;(j+1)<=time;j++) printf(”n Name of %dth person is %s who live in%s.”,j+1,name[j],changwad[j]);} 4 strlen() ,strcmp(),strcpy(),strcat() string.h #include <string.h>strlen() strlen(”string constant”); strlen(string variables);
  24. 24. strlen1.c strlen()/* strlen1.c */#include <stdio.h>#include <conio.h>#include <string.h>char word[100]; int length;void main(void){ clrscr(); printf(”Please enter yourstrings.”); gets(word); length = strlen(word); printf(”Your strings is %s.”,word); printf(”nThelength of strings is %d”,length);} strcmp() 2 strcmp(stringvariable1,stringvariable2); strcmp(stringconstant1,stringconstant2); ASCII
  25. 25. 1 2 1 1 2 0 1 2 1strlcmp1.c strcmp()/* strcmp1.c */#include <stdio.h>#include <conio.h>#include <string.h>char word[100],password[100]={”Bodin”};int compareresult;void main(void){ clrscr(); printf(”Please enter your strings.”); gets(word); compareresult = strcmp(password,word); if (compareresult > 0) {printf(”Your strings < Program strings.compareresult is %d”,compareresult);} else if (compareresult == 0)
  26. 26. {printf(”Your strings = Program strings. compareresultis %d”,compareresult);} else {printf(”Your strings > Program strings. compareresultis %d”,compareresult);}}strcpy() Strcpy(string2,string1); string1 string2 strcpy/* strcpy c */#include <stdio.h>#include <conio.h>#include <string.h>main(){ char word ,word ; clrscr(); printf(”Please enter your st strings :“); gets(word ; printf(”Enter your nd strings : “); gets(word ; printf(”n st strings are :%s nd strings are:%s”,word ,word ;
  27. 27. strcpy(word ,word ; printf(”n st strings are :%s nd strings are:%s”,word ,word ;} strcat() strcat(string2 ,string1);string1 string2/* strcat c */#include <stdio.h>#include <conio.h>#include <string.h>main(){ Char word ,word ; clrscr () ; printf ( “ Please enteryour st strings: ” ) ; gets ( word ; printf(”Enter your nd strings : “); gets(word ; printf(”n st strings are :%s nd strings are:%s”,word ,word ; strcat(word ,word ; printf(”n st strings are :%s nd strings are:%s”,word ,word ;}
  28. 28. char, int, long,float, double, unsigned int, unsigned long int, • 2 1. Global Variable 0( 2. Local Variable • , , ,.....; • 1.char 1 1‘A’ , ‘b’ , ‘1’ , ‘?’ 2.integer -32768 32767 2 5- 10 2534
  29. 29. 3. long 2 long int ) 4. float a.b x 10e 4 3.4E-38 3.4E+38 6 10.625 -6.67 5. double float 2 8 1.7E-308 1.7E+308 6. unsigned unsigned intChar 8 ASCII character (-128 127)Unsignedchar 8 0-255Int 16 -32768 32767long int 32 -2147483648 2147483649
  30. 30. 3.4E-38 3.4E+38Float 32 6 1.7E-308 1.7E+308Double 64 12Unsigned int 16 0 65535Unsigned long 32 0 4294967296int 1 1. #include<stdio.h> 2. #define PI 3.14159 3. int area; /* global variable */ 4. main( ) 5. { float radius; /* local variable */ 6. float process() /* function declaration */ 7. printf (“Radius = ?”); scanf (“%f”,radius); 8. process( ); 9. printf(“Area = %f”,area); 10. printf(“%f”,radius); } 11. float process( ) 12. { float radius; /* local variable */ 13 printf(“Radius=?”); scanf (“%f”,radius); 14 area=PI*radius*radius;
  31. 31. 15 printf(“Area = %f”,area); 16 printf(“%f”,radius); } 2 int a ; a -35768 32767 3 int num1=8; num1 8 4 float money,price ; money price 6 5 char ch=’A’ ch 1 ‘A’ char a,b,c,d; /* a,b,c,dcharacter */ unsigned e; /* e unsigned int */
  32. 32. char key = ?A?; /* keycharacter ?A? */ char name = ?SAM? /* namecharacter ”SAM” */
  33. 33. “ ” “ ” type array float salary3. float float double char long8. float double char long
  34. 34. arraychardouble
  35. 35. http://courseware.bodin.ac.th/computer/AdvancedLevel4/programming/C_language/5.htm http://www.no-poor.com/CandDelphi/ch5_array_and_pointer.htm http://202.143.168.214/uttvc/website/07.html

×