Here's the code snippet:
#include <iostream>
using namespace std;
int main ()
{
double degree;
do {
cout << "Enter a temperature in degrees Celsius: ";
cin >> degree;
} while (cin.fail());
//reassigns degree to conversion to farenheit
degree = degree * (9/5) + 32;
cout << "Your temperature in degrees Farenheit is: " << degree;
return 0;
}
If the input is invalid, the program ends up into an infinite loop, constantly repeating the first cout.
I'm kinda new to C++, and I"m not sure if this is just the compiler acting wonky, or if it's something on my part.
cin.eof()?(9/5)is exactly the same as1(since integer division ignores remainders). Probably easiest to just type1.8.