Why does this tell me that "gender" is an undeclared identifier on line

Change this:

if (y == 1)
    int gender = askGender();

To this:

int gender;
if (y == 1)
    gender = askGender();

Or even better this:

int gender = 0; // default: 0
if (y == 1)
    gender = askGender();

Browse More Popular Posts

Leave a Comment