Вместо использования значений с плавающей запятой:
int act, choice; //choice is type int -> cannot hold float values or during conversion loss of value
//occurs 1.1 would be 1 as an int.
float F;
cout<<"[1.1]Conversion of Celsius to Farenheit" << endl;
cout<<"[1.2]Conversion of Farenhrit to Celsius:" << endl;
cout<<"[1.3]Solving the area of the square" << endl;
cin >> choice;
system("CLS");
if(choice == 1 || choice == 1.1){
Вы можете использовать char
для выбора, и может работать так, как ожидалось.
Например:
char choice;
cout<<"[A]Conversion of Celsius to Farenheit" << endl; // changed 1.1 to 'A'
cout<<"[B]Conversion of Farenhrit to Celsius:" << endl; // changed 1.2 to 'B'
cout<<"[C]Solving the area of the square" << endl; // changed 1.3 to 'C'
и ваш оператор if должен соответствовать выбору выбора, например:
if(choice == 'A' || choice == 'a'){
Есть много способов сделать это иначе.
Демо