C Programming
B. Exercise: Programming Medel (5 points) On the last page you will see the program in the Code Memory. This program computes the capacitance of a set of capacitors connected in series. Capacitance is the ability of a body to store an electrical charge. A material with a large capacitance holds more electric charge at a given voltage, than one with low capacitance. Any object that can be electrically charged exhibits capacitance, however the concept is particularly important for understanding the operations of the capacitor, one of the three fundamental electronic components (along with resistors and inductors). The SI unit of capacitance is the farad (symbol: F), named after the English physicist Michael Faraday. A I farad capacitor, when charged with 1 coulomb of electrical charge, has a potential difference of 1 volt between its plates. Thus the capacitance C (F) of a capacitor is related to the charge q (Coulombs) and the voltage v (volts) by C=q/v When 4 capacitors (ChC2,,C5) are connected in series, the equivalence capacitance, Ce0 of the connected capacitors is given as follows: Ceq1=C11+C21+C31+C41 The following table shows values of charge, voltage, capacitance for 5 capacitors as well as the equivalent capacitance. Use the contents of this table complete the programming model. Modify the programming model to show how variables (simple and structure variables) are stored in the working memory for each function and how the contents of variables is changed by the program. Use the "?" as the variable value when it is created with a declaration (note that parameter variables are initialized with a known value when the function is called). Update the variable value as you trace the program. Use arrows to show how values are copied between the working memory allocated to the function main and the working memory allocated to the function equivalentCapacitance. Note that for structure variables you can use a single arrow when it is the complete structure value that is copied. You may wish to print a copy of the last page before coming to the lab on paper if you are more comfortable filling out the page by hand rather than using Word to complete the electronic version. Show the results to your TA for marks. Tinelude atoligh\} If structures /f structure for aingle capacitor values typedet at ruet Code if Memory Working double Stinf charge on the eapacitor Memory 1 CAPNCLTOR; If atructure for 5 seacdeera in meries typeder atruct il CrPAOITOn o1, CAPACITOR e2; cMAACTTOA a3, cerNeInon e4j 1 CARACITORS IN BKHIRA (1) function prototypen void main (void) 1 CAPACTTOAS_IN_aEfrEB aERC9RAd double "qcepestonet? priati.("p2ease give the charge (Coulomba) it (n ), achaf("tiftif", 6merCapa.e1,9. faercapa. e1, v) 1 Il Compute the equivalent capacitor (f) Diaplay reaten i If Variable det iationa double agCerimel Equivalent dapacitance 7l Inst rudtiona g1CeR = acapa.etex/acapa.e1.9d // met to 1/ct sgSeR m ngSae + mCnpo.ejes/aCapa-a4.qi /l Adda 1/c4 ngCue = 1/ctisenimb netm to 1/(1/ct+1/c2) rocura (gAcat)