I'm working on a simple assignment, in C. I'm having trouble getting the variables to be calculated. My output just repeats a small number and doesn't get anywhere near the value I need. This is my code that I'm utilizing:
#include <stdio.h>
#include <math.h>
#include <iostream>
int main () {
double current, resistance, watts, voltage, miles, power_loss, total_resistance;
watts = 5000000000000000000;
voltage = 100;
resistance = 0.05;
miles = 20;
current = 0;
power_loss = 0;
printf("Distance Power Loss\n");
for(miles = 20; miles <= 100; miles += 10)
{
total_resistance = resistance * miles;
current = watts / voltage;
power_loss = (current * current) / total_resistance;
printf("%g %g\n", &miles, &power_loss);
}
system ("pause");
return 0;
}
This is what my output looks like:
Distance Power Loss
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
1.3477777e-308 0.000000000
Can anyone help?
Lesson 6: Pointers in C++