วันอังคารที่ 30 มิถุนายน พ.ศ. 2552

การบ้าน structure

#include"stdio.h"
struct date
{
int day,month,year;
};
struct Student_information
{
float id;
char name[40];
struct date birthday;
float score;
int age;
char sex;
}std;
void input_data()
{
printf("Student Data\n");
printf("ID = ");
scanf("%f",&std.id);
printf("Name : ");
scanf("%s",&std.name);
printf("Date of birth : ");
scanf("%d",&std.birthday.day);
printf("month of birth : ");
scanf("%d",&std.birthday.month);
printf("Year of birht : ");
scanf("%d",&std.birthday.year);
printf("Enter your Score : ");
scanf("%f",&std.score);
printf("Enter your age : ");
scanf("%d",&std.age);
printf("Enter your sex : ");
scanf("%s",&std.sex);
}
void show_data()
{
printf("\nDisplay Data of student \n");
printf("ID : %.0f\n",std.id);
printf("Name : %s\n",std.name);
printf("birthday : %d-%d-%d\n",std.birthday.day,std.birthday.month,std.birthday.year);
printf("Scare : %.2f\n",std.score);
printf("age : %.d\n",std.age);
printf("age : %.s\n",std.sex);
}
main()
{
input_data();
show_data();
}

ไม่มีความคิดเห็น:

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