After compiling the source code and executing the .exe for debugging, I've found a calculation error when I try to convert celsius into fahrenheit, but I can't seem to figure out the source of it or how to fix it. Really appreciate your help, ppl.
Code://*************************************************************** // Temperature Conversion Program // This program converts a Celsius temperature to its Fahrenheit // equivalent or vice versa //*************************************************************** #include <iostream> #include <iomanip> #include <math.h> #include <stdlib.h> using namespace std; int main() { float f; // degrees farenheit float c; // degrees celsius char option; // type of conversion char exit; // flag for exit cout.setf(ios::fixed, ios::floatfield); // Set up floating cout.setf(ios::showpoint); // pt output format do { // Introduction and Prompt type of conversion cout << "This program converts a Celsius temperature to" << endl << "its Fahrenheit equivalent or vice versa." << endl; cout << "What type of conversion would you like to" << "perform? " << endl; cout << "Enter \"c\" if you want degrees celsius" << endl; cout << "and \"f\" if you want degrees farenheit. "; cin >> option; // Calculation and output if (option == 'c') { cout << "Please enter the temperature in degrees"; cout << " farenheit: "; cin >> f; c = (5 / 9) * (f - 32); cout << setprecision(1) << f; cout << " farenheits equals to " << setprecision(1); cout << c << " celsius." << endl; } // if (option == 'c') else { cout << "Please enter the temperature in degrees"; cout << " celsius: "; cin >> c; f = (9 / 5) * c + 32; cout << f << " farenheits equals to " << c; cout << " celsius." << endl; } // else // Prompt exit cout << endl; cout << "Would you like to exit the program?('y' for yes) "; cin >> exit; } // do while ( exit != 'y'); system("pause"); return 0; } // int main()