#include <stdio.h> int main() { float power,voltage,current; voltage = current = 0; printf(<q>Power calculator.\n</q>); printf(<q>This will calculate the power in watts </q>); printf(<q>when you input the voltage and current.</q>); /*get the voltage*/ printf(<q>Enter the voltage in volts.\n</q>); scanf(<q>%f</q>,&voltage); /*get the current*/ printf(<q>Enter the current in &s.\n</q>); scanf(<q>%f</q>,¤t); /*calculate the power*/ power = voltage * current; printf(<q>The power in watts is %.2f watts\n</q>,power); return 0; }
Output: ====== Electric Power Calculation:-This will calculate the power in watts,when you input the voltage and current. Enter the voltage in volts : 240 Enter the current in &s : 5 The power in watts is : 1200 watts
|