title: C++ Program stopped responding
body: <p>I have made a program that runs and I am able to enter in three variables, length, external diameter and internal diameter. After I enter in internal diameter the program freezes and a window pops up saying the program has stopped responding. The program's purpose is to calculate area, volume, mass, weight etc. of a cylindrical pipe given a number of variable inputs.
  Any help would be appreciated.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define PI 3.14159
  #define ACC_GRAVITY 9.81  /* metres/sec^2 */
  #define FALSE 0
  #define TRUE !FALSE
  
  int main(void)
  {
    /* define the required variables */
  
    float length;
    float ext_diam, int_diam;
    float ext_rad, int_rad;
    float volume;
    float weight;
    float area;
    float mass;
    float width;
    float flag_1, flag_2, thickness, percent;
  
    double no_sheets;
  
    /* define some constants - could use #define */
  
    const float density_convert = 1.0E3;
    const float mm_to_metres = 1.0E-3;
    const float density = 8.03;   /* grams per cm^3 */
  
    /* prompt and get values */
  
    printf("input the length of pipe in metres: ");
    scanf("%f", &amp;length);
  
  do
  {
      flag_1 = FALSE;
      flag_2 = FALSE;
      printf("intput the external diameter of the pipe in milimeters: ");
      scanf("%f", &amp;ext_diam);
      printf("ext_diam: %f\n", ext_diam);
      printf("intput the internal diameter of the pipe in milimeters: ");
      scanf("%f", int_diam);
      printf("int_diam: %f\n", int_diam);
  
      if (ext_diam &lt; int_diam)
      {
          printf("external diameter must be greater than the internal diameter\n");
          flag_1 = TRUE;
      }
      else
      {
          percent = thickness / ext_diam * 100.0;
          if(percent &gt; 2.5 )
          {
              /* do calculations - conversions, area of pipe cross-section, volume
              ** of pipe, mass and weight of pipe */
  
              ext_diam = ext_diam * mm_to_metres;
              int_diam = int_diam * mm_to_metres;
              ext_rad = ext_diam / 2.0;
              int_rad = int_diam / 2.0;
  
              area = (PI * ext_rad * ext_rad) - (PI * int_rad * int_rad);
              volume = area * length;
  
              mass = volume * density * density_convert;
              weight = mass * ACC_GRAVITY;
          }
          else
          {
              printf("Width of pipe too small\n");
              flag_2 = TRUE;
          }
      }
  
  
  } while(ext_diam &gt; 0.0);
  
    /* output the results */
  
    printf("area of cylinder: %f m^2\n", area);
    printf("volume of steel needed: %f m^3\n", volume);
    printf("mass of steel needed: %f kg\n", mass);
    printf("weight of steel needed: %f newtons\n", weight);
  
    /* compute number of sheets of steel needed - 10m is max length of a
    ** sheet */
  
    no_sheets = trunc (length / 10.0) + 1;
    printf("number of 10m long sheets needed: %d\n", no_sheets);
  
    /* assume width of sheets is based on the average of the internal and
    ** external diameters */
    width = 2.0 * PI * (ext_rad + int_rad) / 2.0;
    printf("width of sheets: %f m\n",width);
  
    system("pause");
    return 0;
  }
  </code></pre>