หน้าเว็บ

วันอาทิตย์ที่ 28 มิถุนายน พ.ศ. 2552

การบ้าน "Structure"

#include
#include
void main (){
struct address{
char village[20];
char city[20];
char country[20];
};

struct student{
char name[30];
char surname[20];
char phone_num[15];
int age;
float grade;
char name_of_university[50];
char name_of_faculty[50];

struct address address1;
}student1;
strcpy(student1.name,"Kanyavee");
strcpy(student1.surname,"Kornvasurom");
student1.age=20;
strcpy(student1.address1.village,"Buathong");
strcpy(student1.address1.city,"Nonthaburi");
strcpy(student1.address1.country,"Thailand");
strcpy(student1.phone_num,"0867751413");
student1.grade=2.37;
strcpy(student1.name_of_university,"SDU");
strcpy(student1.name_of_faculty,"Business_computer");

printf("name:%s\n\n",student1.name);
printf("surname:%s\n\n",student1.surname);
printf("phone_num:%s\n\n",student1.phone_num);
printf("age:%d\n\n",student1.age);
printf("village:%s\n\n",student1.address1.village);
printf("city:%s\n\n",student1.address1.city);
printf("country:%s\n\n",student1.address1.country);
printf("grade:%.2f\n\n",student1.grade);
printf("name_of_university:%s\n\n",student1.name_of_university);
printf("name_of_faculty:%s\n\n",student1.name_of_faculty);
}

0 Comment:

แสดงความคิดเห็น