C > Code Snippets
A power calculator in C
A power calculator in C #include
int main() { float power,voltage,current; voltage = current = 0; printf("Power calculator.\n"); printf("This will calculate the power in watts , "); printf("when you input the voltage and current."); /*get the voltage*/ printf("Enter the voltage in volts.\n"); scanf("%f",&voltage); /*get the current*/ printf("Enter the current in amps.\n"); scanf("%f",¤t); /*calculate the power*/ power = voltage * current; printf("The power in watts is %.2f watts\n",power); return 0; }
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting