Could someone help me figure out why my Do/While loop isn't working? (C++)
<p>I'm very new to C++ as well as programming in general. I'm working on a simple program that basically uses the Pythagorean Theorem to find the hypotenuse or leg of a right triangle. I've got the main function pretty much down, but I'm having some issues with getting the program to run again. Basically, when the program asks the user if they'd like to run it again, I want it to close if they input "n" and run again if they input "y". However, the program just runs again, regardless of what the user inputs...</p>

<pre><code>int a;
int b;
int c;
int form;
char ans;

do{

    cout &lt;&lt; "Enter 1 to find the length of the hypotenuse\nEnter 2 to find the length of leg A\nEnter 3 to find the length of leg B" &lt;&lt; endl;
    cin &gt;&gt; form;

    switch (form){

        // Finds length of hypotenuse
    case 1:
        cout &lt;&lt; "\nPlease enter value of leg A" &lt;&lt; endl;
        cin &gt;&gt; a;
        cout &lt;&lt; "\nPlease enter length of leg B" &lt;&lt; endl;
        cin &gt;&gt; b;
        c = sqrt((a * a) + (b * b));
        cout &lt;&lt; "\nThe length of the hypotenuse is approximately " &lt;&lt; c &lt;&lt; endl;
        break;

        //Finds length of side A
    case 2:
        cout &lt;&lt; "\nPlease enter the length of leg B" &lt;&lt; endl;
        cin &gt;&gt; b;
        cout &lt;&lt; "\nPlease enter the length of the hypotenuse" &lt;&lt; endl;
        cin &gt;&gt; c;
        a = sqrt((c * c) - (b * b));
        cout &lt;&lt; "\nThe length of leg A is approximately " &lt;&lt; a &lt;&lt; endl;
        break;

        //Finds length of side B
    case 3:
        cout &lt;&lt; "\nPlease enter the length of leg A" &lt;&lt; endl;
        cin &gt;&gt; a;
        cout &lt;&lt; "\nPlease enter the length of the hypotenuse" &lt;&lt; endl;
        cin &gt;&gt; c;
        b = sqrt((c * c) - (a * a));
        cout &lt;&lt; "\nThe length of leg B is approximately " &lt;&lt; b &lt;&lt; endl;
        break;

    }

    cout &lt;&lt; "\nWould you like to run the program again? Y/N\n" &lt;&lt; endl;
    cin &gt;&gt; ans;

} while (ans == 'y' || 'Y');

return 0;

}
</code></pre>

<p>Any feedback would be greatly appreciated, and I apologize if any of this is sloppy and/or hard to read. This the only the third quick program I've done, and it's the first time that I've tried to implement a feature that lets the user run it again.</p>

<p>Thank you!</p>