++ Homework 2 Files
This commit is contained in:
parent
90652a17ce
commit
6269fbc4ce
10 changed files with 191 additions and 0 deletions
32
Homework2/ohm.c
Normal file
32
Homework2/ohm.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue