crashandburn
2005-03-03 05:18:16 UTC
/* The purpose of this program is to take three integer quantities,
indicating month,day and year, and then displaying the corresponding day
of the week,
the month,the day and the year in a more legible manner*/
#include<iostream.h>
#include<conio.h>
void readinput (int *pmm,int *pdd, int *pyy); //function prototype//
int *convert (int pmm,int pdd,int pyy); //function prototype//
void main()
{
int mm,dd,yy;
int day_of_week;
int *pmm,*pdd,*pyy;
pmm=&mm;
pdd=ⅆ
pyy=&yy;
static char *weekday[]={"Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"};
static char * month[]={"January","February","March","April",
"May","June","July","August","September","October","November",
"December"};
//opening message//
cout<<"DATA CONVERSION ROUTINE\nTO STOP,ENTER 0 0 0"<<endl<<endl;
readinput(pmm,pdd,pyy);
while(*pmm>0)
{
day_of_week = *convert(pmm,pdd,pyy);
cout<<*weekday[day_of_week]<<","<<month[*pmm-1]<<*pdd<<","<<*pyy;
readinput(pmm,pdd,pyy);
}
}
void readinput(int *pmm,int *pdd,int *pyy)
{
cout<<endl<<"Enter mm dd yyyy: ";
cin>>*pmm>>*pdd>>*pyy;
return;
}
//numerical conversion//
int convert(int *pmm,int *pdd,int *pyy)
{
long *pndays;
long *pncycles;
int *pnyears;
int *pday;
*pyy-=1900;
*pndays=(long)(30.42*((*pmm)-1))+*pdd;
if((*pmm)==2) ++(*pndays);
if(((*pmm)>2)&&((*pmm)<8)) --(*pndays);
if(((*pyy%4)==0) && ((*pmm)>2))++*pndays);
*pncycles= (*pyy)/4;
*pndays+= (*pncycles)*1461;
*pnyears= (*pyy)%4;
if((*pnyears)>0)
(*pndays)+= 365 * (*pnyears)+1;
if ((*pndays)>59) --(*pndays);
*pday= (*pndays)%7;
return(*pday);
}
I tried to write this program using all pointers variables. No value
should passed or printed using normal variables ,only pointer should be
used.but unfortuantely this program shows millions of errors. can someone
help fix those..??
indicating month,day and year, and then displaying the corresponding day
of the week,
the month,the day and the year in a more legible manner*/
#include<iostream.h>
#include<conio.h>
void readinput (int *pmm,int *pdd, int *pyy); //function prototype//
int *convert (int pmm,int pdd,int pyy); //function prototype//
void main()
{
int mm,dd,yy;
int day_of_week;
int *pmm,*pdd,*pyy;
pmm=&mm;
pdd=ⅆ
pyy=&yy;
static char *weekday[]={"Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"};
static char * month[]={"January","February","March","April",
"May","June","July","August","September","October","November",
"December"};
//opening message//
cout<<"DATA CONVERSION ROUTINE\nTO STOP,ENTER 0 0 0"<<endl<<endl;
readinput(pmm,pdd,pyy);
while(*pmm>0)
{
day_of_week = *convert(pmm,pdd,pyy);
cout<<*weekday[day_of_week]<<","<<month[*pmm-1]<<*pdd<<","<<*pyy;
readinput(pmm,pdd,pyy);
}
}
void readinput(int *pmm,int *pdd,int *pyy)
{
cout<<endl<<"Enter mm dd yyyy: ";
cin>>*pmm>>*pdd>>*pyy;
return;
}
//numerical conversion//
int convert(int *pmm,int *pdd,int *pyy)
{
long *pndays;
long *pncycles;
int *pnyears;
int *pday;
*pyy-=1900;
*pndays=(long)(30.42*((*pmm)-1))+*pdd;
if((*pmm)==2) ++(*pndays);
if(((*pmm)>2)&&((*pmm)<8)) --(*pndays);
if(((*pyy%4)==0) && ((*pmm)>2))++*pndays);
*pncycles= (*pyy)/4;
*pndays+= (*pncycles)*1461;
*pnyears= (*pyy)%4;
if((*pnyears)>0)
(*pndays)+= 365 * (*pnyears)+1;
if ((*pndays)>59) --(*pndays);
*pday= (*pndays)%7;
return(*pday);
}
I tried to write this program using all pointers variables. No value
should passed or printed using normal variables ,only pointer should be
used.but unfortuantely this program shows millions of errors. can someone
help fix those..??