I keep having errors...

I have read of the program whenever it gets failed but still don't know what's wrong with the source code.
This is what I have:



//
# include <iostream>
using namespace std;

int main(void)

// Start of program

int y = 99; // Last 2 digits of the year
cout<< "Please enter the last two digits of the current year." << endl;
cin>> y;
int d = 99; // Number of the day
cout<< "Please enter the number of the day." << endl;
cin>> d;
int m = 99; // Number of the month
cout<< "Please enter the number of the month." << endl;
cin>> m;
int c = 99; // First 2 digits of the year
cout<< "Please enter the first two digits of the year" << endl;
cin>> c;

int w = 9; // 0 = Sunday ... 6 = Saturday
w = (d + (2.6*m - 0.2) + y + (y/4) + (c/4) - 2*c)%7;


if (w==0) {
}
else {
w == Sunday;
}

if (w==1) {
}
else {
w == Monday;
}

if (w==2) {
}
else {
w == Tuesday;
}

if (w==3) {
}
else {
w == Wednesday;
}

if (w==4) {
}
else {
w == Thursday;
}

if (w==5) {
}
else {
w == Friday;
}

if (w==6) {
}
else {
w == Saturday;
}

cout << "The day of the given date is " << w << "." << endl;


return 0;
}


@skhailie716

You have a few problems.
1... You don't have an opening left bracket after main(). It should look like int main(void){

2... You declare w as int, but never declare what the days of the week are. Maybe you should look into using enum

3... If w does NOT equal the number, then it's being assigned a different variable. Let's say that you had the week days assigned 0 to 6. You enter the required data asked for in the beginning, and let's further suppose w comes out equaling 4. Now, when you get to the bottom of your program, it checks if w is equal to 6, finds it doesn't, so will assigned Saturday value to w even though w was a 4. Besides that, your week days were supposedly already the value of the w.
Topic archived. No new replies allowed.