Program to find out the day of given date

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
 //Program to find out the day of given date
 int d,m,y;
 int td,r,i,j,ny;
 int n=0;
 int ly=0;
 cout<<"Enter the Day (01)";
 cin>>d;
 cout<<"Enter the Month (02)";
 cin>>m;
 cout<<"Enter the Year (2010)";
 cin>>y;
 for(i=1;i<m;i++)
 {
  if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
  n=n+31;
  else if(i==2 && y%4!=0)
  n=n+28;
  else if(i==2 &&y%4==0)
  n=n+29;
  else if(i==4 || i==6 || i==11)
  n=n+30;
 }
 for(j=2010;j<y;j++)
 {
  if(j%4==0)
  ly=ly+1;
 }
 ny=(y-2010)-1;
 td=ly+n+d+(ny*365);
 r=td%7;
 switch(r)
 {
  case 0 :
  cout<<"The day is Sunday ";
  break;
  case 1 :
  cout<<"The day is Monday ";
  break;
  case 2 :
  cout<<"The day is Tuesday ";
  break;
  case 3 :
  cout<<"The day is Wednesday ";
  break;
  case 4 :
  cout<<"The day is Thursday ";
  break;
  case 5 :
  cout<<"The day is Friday ";
  break;
  case 6 :
  cout<<"The day is Saturday ";
  break;
 }
getch();
    return 0;
 
}

Comments

Popular posts from this blog

JavaFX UI /UX Dashboard

JavaFX code for responsive layout