Element)”
String)
1.
One Dimensional Array)
subscript
type array-name[n];
type
array-name
Two Dimensional
Array)
Matrix
type array-name[r][c];
type
array-name
r
2.
int num[3] = {5, 7, 4};
num[0] = 5, num[1] = 7, num[2] =
4
char na e[4] = {„J‟, „a‟, „c‟, „k‟};
2.
float score[10];
…
for (i = 0; i < 10; i++) {
printf(“nEnter students score:
”);
scanf(“ %f”, &score[i]);
for
i
score i
i = 0;
while (!feof (scorefile)) {
fscanf (scorefile, “ %f”,
&score[i]);
i = i+1;
scorefile score
3.
for (i = 0; i < 5; i++) {
printf(“n %5.2f”, score[i])
score
4.
int num [9] = {78, 34, 69, 80,
75, 44, 57, 39, 50};
int maxnum = 0;
…
for (i = 0; i < 9; i++) {
if (num [i] > maxnum) {
num
maxnum
num
maxnum
maxnum
num
maxnum
float score[7] = {43.5, 44.3, 36.3, 28.0,
34.8, 37.6, 49.3};
float total = 0;
float avg;
for (i = 0; i < 7; i++) {
total = total + score [i];
avg = total / 7;
score
total
score
total
String)
string)
char code[6];
[0] [1] [2] [3]
[4] [5]
code
1 1 1 1
1 1
byte byte byte byte
char name[ ] = “MWIT School”;
[0] [1] [2] [3] [4] [5] [6]
[7] [8] [9] [10] [11]
name
1 1 1 1 1 1 1
1 1 1 1 1
byte byte byte byte byte byte byte
byte byte byte byte byte
M W I T S c h o o L 0
2.
scanf(“%s”, scanf(“%s”,name); //
name
gets( gets(name);
printf(“%s”, printf(“%s”,name);
puts( puts(name);
3.
string.h
Header File
.
srting1
string2 string1
string 2 string2
char name1[20] = “Jack ”;
char name2[10] = “Rose”;
…
strcat (name1, name2);
name1 = “Jack Rose” name 2
= “Rose”
strcpy (string1, string2);
srting2 string1
string1
string1 string2
char name1[20] = “Jack ”;
char name2[10] = “Rose Apple”;
…
Strcpy (name1, name2);
namel = “Rose Apple” name 2 =
“Rose Apple”
strcmp (string1, string2);
string1 srting2
string1
string1 string2
string1 string2
char name1[20] = “Jack”;
char name2[10] = “Rose”;
…
x = strcmp (name1, name2);
4.
strcpy (string1, string2);
srting2
string1 string1
string1 string2
char name1[20] = “Jack ”;
char name2[10] = “Rose Apple”;
…
strcpy (name1, name2);
namel= “Rose Apple” name2 =
5
8
9
18
21

งานนำเสนอ1