CYB126-Projects/Homework2/ohm.c
2023-09-27 20:07:19 -07:00

32 lines
No EOL
855 B
C

// header files
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
// local constants
#define AMPS_IN_SYSTEM 15
#define VOLTS_IN_SYSTEM 120
/*
Name: Ohm's Law
Process: Given amps and volts,
calculate how much resistance in Ohms is present in this system.
Function input/parameters: NONE
Function output/parameters: NONE
Function output/returned: NONE
Device input/---: NONE
Device output/---: NONE
Dependencies: included by standard libraries
*/
int main()
{
// define local variables
int calculatedOhms;
// do calculations
calculatedOhms = VOLTS_IN_SYSTEM / AMPS_IN_SYSTEM;
// display results
printf("%d amps of current at %d volts requires %d ohms of resistance.\n",
AMPS_IN_SYSTEM, VOLTS_IN_SYSTEM, calculatedOhms);
// return success
return 0;
}