Find your day from your DOB?

Answer Posted / raghuram.a

Well..Abraham..I am not checking for invalid dates in that
program.
Here is the program that u want..

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

int leap(int y)
{
if(y%4==0&&y%100!=0||y%400==0)
return 1;
else
return 0;
}


int valid(int dd,int mm,int yy)
{
if(dd>31||dd<1||mm>12||mm<1||yy<0)
return 0;
if(mm<8)
if(mm%2==0&&dd>30)
return 0;
if(mm>=8)
if(mm%2!=0&&dd>30)
return 0;
if(mm==2)
{
if(yy%4==0&&dd>29)
return 0;
else
if(yy%4!=0&&dd>28)
return 0;
}
return 1;
}
main()
{
int d,m,y,i,rem;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int days=0;
clrscr();
cout<<"enter date in dd m yyyy format:";
scanf("%d %d %d",&d,&m,&y);
if(!valid(d,m,y))
{
cout<<"\nInvalid date";
getch();
return 0;
}

for(i=1;i<y;i++)
if(leap(i))
days+=366;
else
days+=365;
for(i=1;i<m;i++)
if(leap(y)&&i==2)
days+=29;
else
days+=a[i-1];
days+=d;
rem=days%7;
switch(rem)
{
case 1:cout<<"monday";
break;
case 2:cout<<"tuesday";
break;
case 3:cout<<"wedday";
break;
case 4:cout<<"thursday";
break;
case 5:cout<<"friday";
break;
case 6:cout<<"saturday";
break;
case 0:cout<<"sunday";
}
getch();
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3129


Design an implement of the inputs functions for event mode

2969


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

2228


Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3035


write a simple calculator c program to perform addition, subtraction, mul and div.

3155






why nlogn is the lower limit of any sort algorithm?

2381


Develop a routine to reflect an object about an arbitrarily selected plane

3001


How can you relate the function with the structure? Explain with an appropriate example.

2923


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

3717


What is data _null_? ,Explain with code when u need to use it in data step programming ?

2828


how to test pierrot divisor

2264


Cluster head selection in Wireless Sensor Network using C programming language.

3115


3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.

3326


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

3859


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2337