C++ Using a while loop
<p>I'm trying to write a c++ program to read a line of inputed code (eg The Hat is flat) and get the program to output the number of capital letters the code has. (in this example it would have to output 2). I have written a piece of code using <code>cin.get()</code> but my code is not entering the while loop. Please help me. and please change 'my code' only.</p>

<pre><code>#include &lt;iostream&gt; 
using namespace std; 

int main () 
{
    char y = 0; 
    int capitals = 0; 
    int flag = 0;

    cout &lt;&lt; "Enter your line of words followed by a fullstop: "; 

    while (!flag == -1)
    {
        cin.get(y);
        if ((y &gt;= 65) &amp;&amp; (y &lt;= 90))
        {
             capitals = capitals + 1; 
        }         

        if (y == 46)
        {        
            flag = -1; 
        }
    }

    cout &lt;&lt; "Number of capitals equal is this line is: " &lt;&lt; capitals &lt;&lt; endl;
    return 0; 
}
</code></pre>
