Debugging of code
I know their is something wrong with my formula, but I don't know exactly what? Could you please help me out...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
using namespace std;
int main()
{
// declare variables
float celsius = 0;
const float farenheit = 0;
// display "Enter a ceslius temperature"
cout <<"Enter a celsius temperature" << endl;
cin >> celsius;
//Set Farenheit = (9.0/5.0) * celsius +32
const float farenheit = (9.0 / 5.0) * celsius + 32;
// Display the Farenheit temperature
cout << "That is equal to"<<farenheit<<"degrees farenheit" << endl;
char quitKey;
return 0;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
// using namespace std; // *** avoid use std::cin etc.
int main()
{
// declare variables
// float celsius = 0;
double celsius = 0; // favour double over float
// const float farenheit = 0; // *** define this later, when we know how to initialise it
// display "Enter a ceslius temperature"
std::cout << "Enter a celsius temperature: " ; // << endl;
std::cin >> celsius;
//Set Farenheit = (9.0/5.0) * celsius +32
const /*float*/ double farenheit = ( 9.0 / 5.0 ) * celsius + 32;
// Display the Farenheit temperature
std::cout << "That is equal to " << farenheit << " degrees farenheit\n" ; // << endl;
// char quitKey;
// return 0;
}
|
Topic archived. No new replies allowed.