Why do I have an infinite loop?

As you can probably tell, programming is not my thing, but unfortunately this class is required. I seem to have myself an infinite while loop, but I can't figure out why it won't stop looping. I know I still need to fix the formatting for the cout stuff at the bottom, but I'm more concerned about fixing the loop first.it's supposed to calculate deflection of a cantilevered beam. I tested it using values given to me in the example problem included in my homework
length = 5
height = 6
width = 2
fraction = 240

Divide length by fraction gives you (5/240) = 0.0208333
d is supposed to increase with each loop until it is larger than (5/240), then it's supposed to stop. However, for some reason, it isn't stopping.

#include <iostream>
using namespace std;


int main()
{
double length;
double height;
double width;
int weight(0);
const double E = 2.16e8;

cout.setf(ios::fixed);
cout.precision(4);


int fraction;

cout << "Enter length in feet: ";
cin >> length;

cout << "Enter height in inches: ";
cin >> height;

cout << "Enter width in inches: ";
cin >> width;

cout << "Enter allowable fraction: ";
cin >> fraction;

double I = ((width/12)*(height/12)*(height/12)*(hei…
double numerator = weight*length*length*length;
double denominator = 3*E*I;
double d = numerator/denominator;

while( d <= (length/fraction))
{
double numerator = weight*length*length*length;
double denominator = 3*E*I;
double d = numerator/denominator;

cout << "Weight (lbs) Deflection (in) " << endl
<< "------------ --------------- " << endl
<< " " << weight << " " << d;
weight += 5;
}

return 0;
}
I'm gonna attempt to help you. The "reason" that you have an infinite while loop is because d is never becoming greater than (length/fraction). Can you tell me in words how long you need your while to execute?
Topic archived. No new replies allowed.