So I'm making a C++ program for college. And my program is supposed to keep looping unless the user chooses 0 to exit when it says "Recalculate? (1 = Yes, 0 = Exit)". This is supposed to set the value of the int "more" to either 1 or 0. But for some reason, it looks like the value of the int "more" is still remains at 1, So the program keeps looping.
I'm relatively new to C++ so this could be a really simple mistake I'm making. Anyways, here's my code:
#include <stdio.h>
#include <iostream>
using namespace std;
#pragma warning(disable:4996)
int main() {
const double PI = 3.141592;
double radius, weight, volume, bforce;
double water = 62.4;
int more = 0;
while (more = 1) {
cout << "This program computes Buoyant Force in water given sphere radius." << endl;
cout << "Based on the weight of the sphere, it determines whether the sphere floats or sinks." << endl;
cout << "Enter the radius of the sphere: ";
cin >> radius;
cout << "You entered " << radius << endl;
cout << "Enter the weight of the sphere: ";
cin >> weight;
cout << "You entered " << weight << endl;
volume = (((4 * PI) / 3) * pow(radius, 3));
bforce = volume * water;
cout << "\nBuoyant Force = " << bforce << endl;
if (bforce >= weight)
cout << "It floats!" << endl;
else
cout << "It sunk!" << endl;
cout << "\
https://www.tellpizzahut.one/(1 = Yes, 0 = Exit): ";
cin >> more;
}
system("pause");
return 0; }
Thanks in advance :)