'n'a pas été déclaré dans cette étendue' erreur

Donc j'ai écrit ce programme simple pour calculer le jour d'une date à l'aide de l'algorithme de Gauss trouvé ici.

#include <iostream>
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<<dayofweek(19,1,2054);
    return 0;
}

C'est un programme très simple et ce qui est encore plus étonnant est la sortie.

: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

Il dit que ma variable est inutilisée mais dit alors qu'il n'est pas déclaré? Quelqu'un pourrait-il me dire de quoi de mal.

source d'informationauteur cortex