'was not declared in this scope' error
<p>So I was writing this simple program to calculate the day of any date using the Gaussian algorithm found <a href="http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Gaussian_algorithm" rel="nofollow">here</a>.</p>

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

//Using the Gaussian algorithm
int dayofweek(int date, int month, int year ){
    int d=date;
    if (month==1||month==2)
        {int y=((year-1)%100);int c=(year-1)/100;}
    else
        {int y=year%100;int c=year/100;}
    int m=(month+9)%12+1;
    int product=(d+(2.6*m-0.2)+y+y/4+c/4-2*c);
    return product%7;
}

int main(){
    cout&lt;&lt;dayofweek(19,1,2054);
    return 0;
}
</code></pre>

<p>It's a very simple program and what's even more puzzling is the output.</p>

<pre><code>:In function  dayofweek(int, int, int)’:
:19: warning:  unused variable ‘y’
:19: warning: unused variable ‘c’
:21: warning: unused variable ‘y’
:21: warning: unused variable ‘c’
:23: error: ‘y’ was not declared in this scope
:25: error: ‘c’ was not declared in this scope
</code></pre>

<p>It says that my variable is unused but then says that it isn't declared? Could anyone please tell me whats wrong.</p>
