CSE 101 Computer Programming Start up Structure A

  • Slides: 4
Download presentation
CSE 101: Computer Programming Start up Structure A structure is a convenient tool for

CSE 101: Computer Programming Start up Structure A structure is a convenient tool for handling a list of logically related data items. The concept of structure is analogous to record. Example: To select for the gold medalist, the administrator will create record of: Sr Name Roll CGPA Session Dept Roll: 1 A 1 3. 8 2012 EEE CGPA: 2 B 30 3. 89 2013 EEE Session: 3 C 20 3. 76 2014 EEE Dept: ------- Structure help us to that

CSE 101: Computer Programming Structure Sr 1 2 3 --- Name A B C

CSE 101: Computer Programming Structure Sr 1 2 3 --- Name A B C --- Roll 1 30 20 --- Start up CGPA Session Dept 3. 8 2012 EEE 3. 89 2013 EEE 3. 76 2014 EEE ------- struct Gold. Medal { int Sr; char Name[30]; int Roll; float CGPA; int Session; char Dept[5]; }; Struct Gold. Medal Std 1, Std 2, Std 3 Now declare variable std 1, std 2, std 3 of type struct Gold. Medal.

CSE 101: Computer Programming Structure struct Gold. Medal { int Sr; char Name[30]; int

CSE 101: Computer Programming Structure struct Gold. Medal { int Sr; char Name[30]; int Roll; float CGPA; int Session; char Dept[5]; }; main() { Struct Go. Medal Std 1, Std 2; printf(“Enter Sr. Name, Roll, CGPA, Seesion and Dept of a student”); scanf(“%d%s%d%f%d%s”, &Std 1. Sr, Std 1. Name, &Std 1. Roll, &Std 1. Session, Std 1. Dept); Sr 1 2 3 --- Name A B C --- Roll 1 30 20 --- Start up CGPA Session Dept 3. 8 2012 EEE 3. 89 2013 EEE 3. 76 2014 EEE ------- printf(“Enter Sr. Name, Roll, CGPA, Seesion and Dept of a student”); scanf(“%d%s%d%f%d%s”, &Std 2. Sr, Std 2. Name, &Std 2. Roll, &Std 2. Session, Std 2. Dept); printf(“Sr. t. Namet. Rollt. CGPAt. Sessiont. Dept); printf(“%dt%st%dt%ft%dt%s”, Std 1. Sr, Std 1. Name, Std 1. Roll, Std 1. CGPA, Std 1. Session, Std 1. Dept); printf(“%dt%st%dt%ft%dt%s”, Std 2. Sr, Std 2. Name, Std 2. Roll, Std 2. CGPA, Std 2. Session, Std 2. Dept); }

CSE 101: Computer Programming Union Start up

CSE 101: Computer Programming Union Start up