Temp conversion for a bigger problem
Mar 14, 2014 at 7:34pm UTC
I'm trying to do temp conversion for a bigger problem but it keeps outputting the same number every time which I know is wrong. Im testing this bits at a time to hopefully not have a ton of problems at the end. Can I get any help here please?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//Cody Brown MidTerm Project Diode Current Flow
#include <iomanip>
#include <cmath>
#include <iostream>
using namespace std;
//Define Variables
const double ILeak = .0000015;
double tempF = 0;
double volt = 0;
const double q = (1.602 * pow(10,-19));
const double k = (1.32 * pow(10,-23));
double tempK = 0;
int main(){
cout << "Input Temperature in Degrees Fahrenheit \n" ;
cin >> tempF;
double tempK = (((5/9)*(tempF-32))+273.15);
cout << tempK;
system ("Pause" );
return 0;
}
Mar 14, 2014 at 7:46pm UTC
5/9
is equal 0. You are performing integer division here. Use 5.0/9.0
instead.
Mar 14, 2014 at 7:51pm UTC
thank you much! Obviously I am new to programming
Topic archived. No new replies allowed.