Find the Day Against a Date of Year

08:29 0 Comments A+ a-

Problem:
Find the day (i.e. Monday, Tuesday etc.) against the date entered by the user. Suppose it was Tuesday on January 1.
Solution:
cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<date<<endl; dayName=((date-1)%7); } else if(month==2){ days=31+date; cout<<"The day number for"<<" "<<date<<"# include <iostream>
using namespace std; int main() { int month; int date; int days; int dayName; cout<<"Enter the Month"<<endl; cin>>month; cout<<"Enter the Date"<<endl; cin>>date; if(month==1){-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==3){ days=59+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==4){ days=90+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==5){ days=120+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==6){ days=151+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==7){ days=181+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==8){ days=212+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==9){ days=243+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==10){ days=273+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==11){ days=304+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else if(month==12){ days=334+date; cout<<"The day number for"<<" "<<date<<"-"<<month<<" "<<"is"<<" "<<days<<endl; dayName=((days-1)%7); } else cout<<"Months not in range"<<endl; if (dayName==0) cout<<"Tuesday"<<endl; if (dayName==1) cout<<"Wednesday"<<endl; if (dayName==2) cout<<"Thursday"<<endl; if (dayName==3) cout<<"Friday"<<endl; if (dayName==4) cout<<"Saturday"<<endl; if (dayName==5) cout<<"Sunday"<<endl; if (dayName==6) cout<<"Monday"<<endl; return 0; }