You are on page 1of 7
Kolej Kemahiran Tinggi MARA Ledang, Johor LEDANG PRACTICAL 2 | DIPLOMA IN BIOMEDICAL ELECTRONICS ENGINEERING PROGRAM /CLASS | (048 DKD, DKG, DKL, DKT) SESSION JANUARY JUNE 2023 [SEMESTER | 1 DBV10023 / BASIC C [copescourse | payiooes aA! SEHEETNO | PA2 NO OF STUDENTS WEEK DURATION 4 HOURS VENUE LAB MASLIHA BINTI SAYUTI, eee NIK MD HAFIZUL HASMIE BIN MOHAMED SUHAIMI | SeEeseeeeeeeeCeeeeeceeeceeeee STUDENT NAME / MATRIC NUMBER | UNIT 4: POINTER AND ARRAY ie UNIT 5: STRINGS AND STRUCTURES 44 Pointers 42 Array SUB-TOPIC 5.1 Strings 5.2 Structures LEARNING At the end of this iab, student should be able to OUTCOME 4. Determine library functions for string operations. 2. Describe the uses of structure in programming, TOOLS / 4. Computer EQUIPMENTS / 2, © Compiler MATERIALS. 3._Drawio DRAWING AND DATA NIL You are requiring to write, compile and execute given programs inside this Job sheet using C Compiler software. Adlicsctdodad Details of the programs are described in following procedure. Page 10f7, PROCEDURE (PLOS, P3, DK6, DP1-DK6) STEP KEYPOINT TASK 1 Write a C program based on output below and the given data. 4. Student 4 please enter student 1 name : ali please enter student 2 nane + abu | f please enter student 3 name : ahwad leudent 1 name oli Ieudent 2 nave abu FReudent 2 nane abod Process returned 22 (Oxi6) execution tine : 6.124 Press ony key to contimie 2. Student 2 Jptease enter color 1: blue Dpteese enter color 25 green [please enter color 3: block kolor 1 4s blue olor 2 is green ler 3 is black Process returned 18 (x2) excution tive £20.09 + ress any Key £9 continue. 3. Student 3 Se i pplease enter car brand 1: perodua please enter car brand 2: toyota please enter car brand 3. + honde ‘cor brand 4 is porodua ‘Ear brand 2 is toyota ‘ear brand 3 honda Process returned 22 (Ox18) execution tine + 12.347 5 Press any kay to continue Page 2 of 7 Using given variable: a. student[10][10} b x ey Using FOR control instruction as the looping statement Add data as belows: a. Student 1 : Karim b. Student 2: Aminah c. Student 3: Jamal Using given variable: a, color[10]{10] boy k Using FOR control instruction as the looping statement Add data as belows: a. Color 1: Orange b. Color 2 : Black ©. Color 3: Yellow Using given variable: a. brand{t0][10] bm aon Using FOR control instruction as the looping statement Add data as belows: a, Brand 1 : Proton b. Brand 2: Mazda c. Brand 3: Haval 4. Student 4 please enter subject 1 + english please enter subject 2 + network please enter subject 3: physics Subject 1 nae $6 english Subject 2 nane 35 network Subject 2 nae Se phystes Process returned @ (0x0) execution tine : 57.071 5 Press any key to continue. Using given variable: a, subject[10][10] bt ar Using FOR control instruction as the looping statement ‘Add data as belows: a. Subject 1: Music b. Subject 2 - Sejarah c. Subject 3: Tasawwur TASK2 4. Student 1 Requirement Refer to Appendix 1 a. Copy str1 into str3 Edit the code. b. Compare str1 to str2, Compile and run the code. str to str3 ¢. Screenshot output 2. Student 2 Requirement a eee a. Concatenate str and Compile and run the code. aoe Pl b. Get total length of str after concatenation c. Screenshot output 3. Student 3 Refer to Appendix 2. Requirement: 7 Edit the code. a. Copy details from Compile and run the code. Bookt into Book2 using individual element method b. Display details for both Book! and Book2 ©. Screenshot output 4. Student 4 Requirement: Refer to Appendix 2. a. Copy details _ from Edit the code. Bookt into Book2 Compile and run the code. using structure assignment method b. Display details for both Book1 and Book2 ©. Screenshot output Page 3 of 7 RESULT (PLOS, DP1-DK6) TASK 1 Write your answer in separate sheets of paper TASK 2: Write your answer in separate sheets of paper DISCUSSION (PLOS, DP1-DK6) 1, Define a struct and syntax declaration or struct in C2, 2. Describe an array and its advantages in C? 3. Explain pointer and how to declare a pointer? 4, Justify why you get the output (fer each student) 5. Discuss the advantages and disadvantages of using arrays, Page 4 of 7 CONCLUSION (PLOS, DP1-DK6) REFERENCE Prepared by: Page 5 of 7 APPENDIX 4 #include #include int main () { char stra[12] char str2[12] char str3[12]; int len; fello"; “world” 5 return 0; Page 6 of 7 include #include struct Books { char title[50]; char author[50] ; char subject[100]; int book_id; Bb int main() { /* Declare Book1 of type Book */ struct Books Booki; /* Declare Book2 of type Book */ struct Books Book2; /* Declare Book2 of type Book */ struct Books Book3; /* book 1 specification */ strepy(Book1.title, "C Programming"); strepy(Book1.author, "Nuha ALi"); strepy(Book1.subject, "C Programming Tutorial"); Book1.bock_id = 6495407; return 0; Page 7 of 7 APPENDIX 2

You might also like