# Work done in a Capacitor

Capacitor is an electrical component that stores charge. As charges are stored, potential energy in the capacitor also increases. In this post, I would like to explain how to calculate the energy stored in a capacitor.

##### Question

The switch is closed at time t = 0 s. During the time interval from t = 0.0 s to t = 4.0 s, 15 mC charge passes through the resistor.

Calculate the energy transferred by the battery during this 4.0 seconds and the energy stored in the capacitor after 4.0 s.

#### Definition of Potential Difference

In many textbooks, we learnt that the potential difference across a component is the energy released for every unit charge passing through it.

$V=\frac{W}{Q}$

If we are to calculate the energy released by the battery, it would be

$W=V \times Q = 9.0 \times 15 \times 10^{-3} =0.135 \text{J}$

#### Energy stored in the capacitor

However, the energy stored in the capacitor cannot be 0.135 J. This is because a capacitor’s potential difference changes as it stores charge. The equation above requires that the p.d. remains constant. Hence, we need to use another formula.

Since capacitance is defined as the charge stored for every unit potential difference,

$Q=VC$

i.e. the charge stored is directly proportional to the potential difference across it. Since the work done is the area under a charge-voltage graph, we will use the formula for a triangle.

$W=\frac{1}{2}QV$

At time t = 4.0 s,

$V=\frac{15 \times 10^{-3}}{2000 \times 10^{-6}}=7.5 \text{V}$

Hence,

$W=\frac{1}{2} \times 15 \times 10^{-3} \times 7.5 = 0.05625 \text{J}$

#### Lost energy?

The energy stored in the capacitor(0.05625 J) is not the same as the energy transferred from the battery(0.135 J) because heat is lost through the resistor as current flows.

// Challenge 2

#include <iostream>

int main ()
{
int marks[10];
int total = 0, max = -1, min = 100;

for (int i = 0; i < 10; i++) {
std::cout << "Enter mark " ;
std::cin >> marks[i];

total += marks[i];
if (max < marks[i]) {
max = marks[i];
}
if (min > marks[i]) {
min = marks[i];
}
}

std::cout << "The maximum mark is " << max << std::endl;
std::cout << "The minimum mark is " << min << std::endl;
std::cout << "The average mark is " << total/10.0 << std::endl;

return 0;
}