Structure 1 Structure student name surname age char

  • Slides: 32
Download presentation
Structure 1

Structure 1

�������� (Structure) student ��� � ������ � name surname age char sex[7]; sex float

�������� (Structure) student ��� � ������ � name surname age char sex[7]; sex float grade; grade char name[20]; char surname[30]; int age; 5

�������� (Structure) struct book { char code[7]; float price; int year; } code 7

�������� (Structure) struct book { char code[7]; float price; int year; } code 7 bytes price year 4 bytes 2 bytes 6

�������� struct student { char int char float }; struct date { int };

�������� struct student { char int char float }; struct date { int }; struct sdate { char }; name[20]; surname[30]; age; sex[7]; grade; day, month, year; day[3], month[3]; year[5]; 8

�������� struct student { char name[20]; char surname[30]; int age; char sex[7]; float grade;

�������� struct student { char name[20]; char surname[30]; int age; char sex[7]; float grade; } student 1; struct date { int day, month, year; } vacation, birthday; 11

�������� n ������������� struct student { “������ ” ����� char name[20]; char surname[30]; int

�������� n ������������� struct student { “������ ” ����� char name[20]; char surname[30]; int age; char sex[7]; float grade; } student 1; � 12

�������� #include <stdio. h> struct income { float salary, bonus; int age; }; void

�������� #include <stdio. h> struct income { float salary, bonus; int age; }; void main(void) { struct income somsri; somsri. salary = 18000. 00; somsri. bonus = 30000. 00; somsri. age = 23; } 15

����������������� #include <stdio. h> #include <string. h> struct letter { char name[20]; char address[30];

����������������� #include <stdio. h> #include <string. h> struct letter { char name[20]; char address[30]; char message[40]; }; void main(void) { struct letter first; printf("Enter name : "); gets(first. name); printf("Enter address : "); scanf("%s", first. address); strcpy(first. message, "How r u? "); printf("n. NAME is %s", first. name); printf("n. Address is %s", first. address); printf("n. Message : %s", first. message); } 17

���� n ��������� ������ #include <stdio. h> main() { struct profile { char name[20];

���� n ��������� ������ #include <stdio. h> main() { struct profile { char name[20]; int age; char grade; }; struct profile student[10]; } 22

������ struct profile { char name[20]; int age; char grade; } student[3]; name 20

������ struct profile { char name[20]; int age; char grade; } student[3]; name 20 bytes age 2 1 grade student[0] student[1] student[2] 23

�������� #include <stdio. h> #include <string. h> main() { struct profile { char name[20];

�������� #include <stdio. h> #include <string. h> main() { struct profile { char name[20]; int age; char grade; }student[10]; clrscr(); strcpy(student[0]. name, “Manee”); student[2]. age = 12; student[4]. grade = ‘A’; printf(“%sn”, student[0]. name); printf(“%dn”, student[2]. age); printf(“%cn”, student[4]. grade); } 25

�������� #include <stdio. h< #include <conio. h< void main() } struct } char id[10;

�������� #include <stdio. h< #include <conio. h< void main() } struct } char id[10; [ char name[30; [ int age; { std[4; [ int i; printf("Please <Enter> for Input 5 record: n; (" for(i=0; i<4; i(++ } printf("-------------------------n; (" printf("RECORD # %d n", i+1; ( printf("t. CODE; (" : scanf("%s", std[i]. id; ( 26

printf("t. NAME; (" : scanf("%s", std[i]. name; ( printf("t. AGE; (": scanf("%d", &std[i]. age;

printf("t. NAME; (" : scanf("%s", std[i]. name; ( printf("t. AGE; (": scanf("%d", &std[i]. age; ( { printf("n------ OUT PUT ------ n; (" printf(" CODE NAME for(i=0; i<4; i(++ AGEn; (" } printf("%s %s %d n", std[i]. id , std[i]. name, std[i]. age; ( { getch; () { 27

28

28

���� n ���� union my. Union { int i; float x; }; union my.

���� n ���� union my. Union { int i; float x; }; union my. Union u 1; my. Union i x u 1 ������� 4 ���� 31