clc; v=10; //voltage in volt t=2; //time in sec r=40; //resistance in ohm p=(v^2)/r; //power e=5/5; //energy in Watt disp(p,"Power in Watt = "); //displaying power disp("2 W resistor is adequate."); //displaying result