You are on page 1of 16
IGRAHIM SULTAN ELECTRICAL ENGINEERING DEPARTMENT. DEC20012 - PROGRAMMING FUNDAMENTAL PRACTICAL WORK : 6 TITLE ‘Array PROGRAMME baka *-FUAN NOOREIZA GINTTABOUL AZIZ LECTURER z [ GROUP MEMBERS ARE: REGISTRATIONNUMEER STUDENT 1 ‘TNURUL ELIANA NATASYA BINT SHAW PaO STUDENT? SIT HAF BINT ZAI PORTO STUDENTS = YOVADURRERRAT AL PRRAWESWARAN SORETTTOE STUDENT 4 4 PRACTICAL SKILL EVALUATION (CLO2, PLOOS) SCORE caters ] Good [avenge [weak | verweak [s.25] st | s2 [so |sa aabect suis | udens | prepare students prepare ty | propare oy | dong 6 ot | prover by ington ot | Beton rae | theta | Song aon of be | Bag 404 tte pare | reeaie | ipanaot_ | Ltarng)®™ | trasanaet | tape fm Learogighen | [Serznpeven | were | earsa)gven | Lemringgren | x intrepraaea’ | iiepncteal | acca” | mtemacea’ | mepaceal sreataire |e notre | thous | shecestnone | sacs sxe wer | wens Reps | pace worcis | wore *" " implemented. work is. ‘implemented. implemented, loners REET | KER ST] Rs ao | RAOAIOTS [ATS Fuss [actoowal | aeatiecienar | otatoiel” | io erenos | tao%elenes |, oS crosinte | hbemoyam’” | erosnte | mie pepem” | min rogam ogee ogo Reker aes | A Cada ase | Rstaen ane | AGATA | ASE SETS compite | complete 10% tox | complet | complete 40% | complete 20% Seno ‘otetatomenisin | ofstatomentsin | 60% of oteiatomorisin | ofstatomentsin |X aepoman | mepeaan | utenansin | tepogan | fwepeorm aetogan Aaa anpunnsthe room wh Aster ate . . Ashden 0 Astunt ate to | A student abet iret 100% of | Revputiethe | mampulete | Neriejaatha | manipute te & ‘program with wrePresrem | program with program with specifications meets 80% of |_| With meets 40% of | meets 20% of xo wa and the code is | meats 60% of | {he Wwoterganizea | *P2eHeat spectcatons | Peele ‘: covey co melee build the ‘Astudent can fowctat | Astutontcan | asteentcan | Ashentcan | Astute Sysana | butatee "| uta "| butane | Buldtbe ea | Bovarsuonce | owen win | tower with a bu correctly fom | one arrorinthe | two errors in more than x2 wa Septizend” | ynodeor | ttesymodior | teaynnotar | Hee erorin Suiswel” | Sequccot | Seecsneest” | samstnee ar” | Ressment ‘organized and | step ‘step ‘step = aye Bissay ac Diplay Ram | Olelay ——| Danny ae] Oana SRS ispuy | wirtoon [wants | apn | wae | stra ~ correctly: 60% correctly: | correctly: ro remens ‘Mestloments Feerrehty resamuaa | semmpee, [x2 Actsiert hes A student has ‘Astudent has | 9 student has. Astudent has. performed the the | performed yerformed the formed the Practcalwork | Performed te | the pracical | Performeduie | performed x2 warms | out || Seen | ttn [sumone | Sopot om 5--LAB REPORT ASSESSMENT ‘SCORE Excellent, Good Average Weak ‘Very Weak ‘SCALE ‘SCORE wee | Conclusion | and support the ‘evidence to 3. butdidnot | results, 2% STUDENTS: $1[S2[S3|S4 Total marks 100% TITLE: Array [COURSE LEARNING OUTCOME(CLO): ICLO2 : Build programs written in C language for assigned mini project during practical work sessions, (P4, PLO 5) OBJECTIVE: Upon completion the experiment, students should be able to : 1. Describe the structure of ARRAY(P1) 2. Fixes Array statement(P3) {3. Complete and manipulate Array statement(P4). J4. Display the output of Array(P4), THEORY 4. Detnton of ARRAY’ 2. Dedlaing an ARRAY EQUIPMENT / TOOLS Computer, C programming language { Dev-epp, codeblock, dl Preparation before Practical Work 6 (Independent Learning (NF2F}): DEFINITION OF ARRAY ‘Arrays a Kind of data stucture that can store a fxed-size sequential colection of elements of the same type ‘An array is used to store a collection of data but itis often more useful to think of an array as a collection of variables of the same type Each memory location in array is referred by array’s name and location memory index ‘Nl arrays consis of contiguous memory lations. The lowest adress corresponds tothe fst element andthe highest address to the last element First Element Last Element | | Nambers{0} | Numbers{t] | Numbers{2] | Numbets/3] | DECLARING AN ARRAY To declare an array in C, a programmer specfes the type ofthe elements and the number of elements required by an array as follows: data types arrayNamefarraySize int Month(10}; This is called single- dimensional aray. arraySize must be integer and >0 DECLARING AN ARRAY ‘One Dimensional Array (9 = For printing each mark in a array: a for (i=0; i < 10; i++) [3] printf("%d ",| 4 (5) f (8) 1} TWO DIMENSIONAL ARRAY The simplest form of multidimensional aray is the hwo-dimensional array, A twoeimensional ary i, in essence, a list of one-dimensional arays. To declare @ ho-dimensional integer aay of size [ely], you would write something as follows intDayst3H5); Column 9 Column 4 Column 2__Columa 3 zowe [ aionoy | atoury | cena | ona) Row 1 smo | attyty | atsa2y 1131 Row 2 | azo) | a2uty | o2u2y | 1213) Exercise 1: Student should key-in all the source code as shown below and compile! run the program to get the ‘output, Please state the output result on the given column include int main ()( int of 10 jf nis an aray of 10 integers *! inti I" intialize elements of aray n to 0" for (1= 0;1< 10; i++ ){ [i] = i+ 100; P set element at location i toi + 100 + /" output each array element's value *! for j= 0; < 10; j++) print{"Element(iéa) = Shc’, j nj retum 0; } OUTPUT: When the above code is compiled and executed, it produces the following result - Element{a] = 100 Element{t] = 101 Element(2} = 102 Element{3] = 103, Element(4] = 104 Element(s] = 105 Element(6] = 106 Element{7] = 107 Element(8} = 108, Element(g] = 109 Practical Assignments 1 Fixes Program 1: The following program contains 5 types of error which is syntax errors, run-time error, Linker Error, misused of % operator and semantic error. Students need to verify the error and fix it before their can get the correct output. 7 Program to find the average of n numbers using arrays Hinclude int Main() { int marks{10), i, n, sum = 0, average: prin"Enter number of elements: *) scanf("%hd", 81); for(i=0;icn; +i) { print("Enter number%bd: scant("hd", &marks{); J adding integers entered by the user to the sum variable sum += marks|i} inta,b, atbec; t average = sum/0; print‘Average = ‘bea, average), return 0; Average = 39 Correction: printf(center'ninber of elenent Seantxe", printé(center number art("xd", earke3]); t Peet Sin s+ marks{ is ae average = sur/as prints(caverage = 2", aver return Practical Assignments 2 ‘Complete Program Fill the blanks to complete this program. include void main() printf (" \asort elements of array in ascending order printf (" print f(“Input the size of array scant ("Kd", printf("Input Xd elements in the array :\n"5n)5 for(i=0;4enji++) { printf("element - Sd ceont(llhesrraciiy; fora { for@j=ists jen J++) t if (arri{¥] 5 int main() 6 { 7 int resistance[10¢]; 8 int n,i,sum=e5 3 printf("Input the size of array :"); 10 scant ("Xd",8n)5 11 print#("znput %d element in the array :\n",n); 12 for (i=0;i) Output: Ciemc aa mee) aL a We Tale NV 12020 Er) 28088 So after 16.72 seconds with return value @ Caeser

You might also like