You are on page 1of 6
Kolej Kemahiran Tinggi MARA Ledang, Johor LEDANG PRACTICAL 1 DIPLOMA IN BIOMEDICAL ELECTRONICS ENGINEERING PROGRAM/CLASS | (nx DKD, DKG, DKL, DKT) | SESSION [JANUARY = JUNE 2023 SEMESTER | 1 DBV10023 / BASIC C CODE COURSE PROGRAMMING SEHEETNO | PAI NOOF STUDENTS | WEEK DURATION | 4 HOURS VENUE LAB MASLIHA BINTI SAYUTI, feet: NIK MD HAFIZUL HASMIE BIN MOHAMED SUHAIMI STUDENT NAME / MATRIC NUMBER UNIT 2: CONTROL INSTRUCTIONS PIC tert UNIT 3: FUNCTIONS 2.1 Decision Control Structure eae 2.2 The Repetition (Iteration) Structure 3.1 Functions (Nothing Nothing) "Al the end of this lab, student should be able to | 1. Describe that there are few ways for taking decisions in LEARNING a program. First way is to use the if-else statement and OUTCOME second way is to use the conditional operators 2. Draw and relate between the statements used and flowcharts to represent the overall programs. [TooLs) 4. Computer - EQUIPMENTS / 2. © Compiler MATERIALS: 3. Drawi.o DRAWING AND DATA te You are requiring to write, compile and execute given heater programs inside this Job sheet using © Compiler software. Details of the programs are described in following procedure. Page 1 of 6 PROCEDURE (PLOS, P3, DK6, DP1-DK6) _STEP KEYPOINT 4. Refer to flowchart in|1.1 Translate the flowchart into a correct and ‘Appendix 1 functionable C Programming by using C compiler. 2. Refer to flowchart in |2.1 Draw a flowchart base on syntax using Drwal i. Appendix 2 DISCUSSION (PLOS, DP1-DK6) 1. Why do we need the (a) #include and (b) #define directive in C programs? 2. How are functions called from main()? 3. Describe the difference between while statement and do...while statement, 4. Based on syntax of Procedure 1, classify the function definition, function call and function declaration. 8. Justify an infinite loop. Page 2 of 6 CONCLUSION (PLOS, DP1-DK6) REFERENCE Prepared by: Checked by: 19 el WR ag Name: Designation: _ ¥/Y/2023 Page 3 of 6 APPENDIX 1 / Temperature Enter Humidity Page 4 of 6 include void menu (void); main() { int menu, current,resistor, loop=0; Float voltage; printf("Enter value of resistor(R) and current(1): scanf ("Xd Xd", resistor, ¤t); while (loop=-@) { print#("\nchoose your formula: \n"); print#("1. Power (P=1V)\n"); printf("2. Voltage (V=IR)\n"); print#("3. Exit\n\n"); print#("Your choice: "); scan#("Xd", &menu); menu() 5 t } Void menu(void) { switch(choose) { case 4: printf("enter value voltage: "); scan#("xd" voltage); powerscurrent*voltage; break; case 2: voltage=current*resistor; break; case 3: printf("Thank you.\n"); break; default printf("Re-enter\n break; if (monueet) { printf(*Value of Power is X0.2#", power); Loop=2; else if(monu: t printf(“Value of Voltage is %0.2F*, voltage); loop=2; + else if(menu t loop=15 } else t oop=05 } } APPENDIX 2 Page 5 of 6 Page 6 of 6

You might also like