อาร์เรย์ หมายถึง กลุ่มของข้อมูล ที่มีชนิดของข้อมูลเป็นชนิดเดียวกัน การอ้างถึงกลุ่มของชุดข้อมูลนี้จะอ้างด้วยชื่อของตัวแปรเดียวกัน
1.อาร์เรย์มิติเดียว คือจะเก็บข้อมูลในแถวเดียวไม่ว่าจะเป็นแนวนอน หรือ แนวตั้ง ตัวแปร 1 ตัวจะสามารถเก็บค่าได้หนึ่งค่า หากเป็นตัวแปรแบบ Array ตัวแปรหนึ่งตัวจะสามารถเก็บค่าได้มากกว่า 1 ค่า
เมื่อมีการใช้งาน Array
2.อาร์เรย์หลายมิติ จะมี 2 มิติ หรือ 3 มิติ จะแตกต่างจากอาร์เรย์มิติเดียวตรงที่ตัวห้อย คือ ตัวห้อยของอาร์เรย์จะมีขนาดของแถวและขนาดของคอลัมม์มาเป็นตัวบอกจำนวนสมาชิกด้วย รูปแบบของอาร์เรย์มิติหลายมิติ
Structure คือ โครงสร้างข้อมูลที่มีประเภทข้อมูลแตกต่างชนิดกันได้ สมาชิกอาจเป็น จำนวนเต็ม ทศนิยม พอยเตอร์ ก็ได้ มื่อต้องการอ้างถึงตัวแปรในโครงสร้างของ structure จะใช้ . มาเป็นตัวอ้า
การบ้าน Structure
#include
struct date{
int day;
int month;
int year;
};
struct order {
char name[20];
char last_name[20];
char address[30];
char telephone;[12];
char type[20];
float price;
struct date paymoney;
}order1;
void input_data()
{
printf("order data\n");
printf("day dd=");
scanf("%d",&order1.paymoney.day);
printf("month mm=");
scanf("%d",&order1.paymoney.month);
printf("year yyyy=");
scanf("%d",&order1.paymoney.year);
printf("Name =");scanf("%s",&order1.name);
printf("Last name =");
scanf("%s",&order1.last_name);
printf("address=");
scanf("%s",&order1.address);
printf("telephone =");
scanf("%s",&order1.telephone);
printf("type=");
scanf("%s",&order1.type);
printf("Price =");
scanf("%f",&order1.price);
}
void show_data()
{
printf("Display Data of order\n");
printf("Day=%d-%d-%d\n",order1.paymoney.day,order1.paymoney.month,order1.paymoney.year);
printf("name= %s Last Name= %s\n",order1.name,order1.last_name);
printf("address=%s\n",order1.address);
printf("telephone= %s\n",order1.telephone);
printf("type=%s\n",order1.type);
printf("Price= %f\n",order1.price);}
main()
{
input_data();
show_data();
}