plz help dis out

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define TRUE 1
#define FALSE 0
main()
{
/*int yrow=20,
int mrow=22,*/
int m=0,i;int day=1;
int week=6;
/*m,week and day are given initial values corresponding to 2011*/
int SR=8;//starting row for the main body of calender
int SC=8;//starting column for the main body of the calender
int diff;//difference between the year of calender sought and 2011
int leap;
int *cmonth=(int *)malloc(366);
int *cday=(int *)malloc(366);
int *cweek=(int *)malloc(366);
int year=2013;
/*m,day and week are integer variables
m=month ranging from 0-11
day=days varying from 1-28,30,29,31(dependeing upon month and year,leap or not)
weeek= symbolises week day from 0-6
respectively and is used to feed data into the pointer arrays which
contain the calender data cyear,cweek,cday;*/
clrscr();
diff=(2011-year);
if(year%4==0)
{leap=TRUE;}
else
{leap=FALSE;}
if(diff>0)
{week=6-(diff%7);}//starting value of week for the sought year
else
{week=6+(diff%7);}



i=0;
while(i!=(365+leap+1))
{cmonth[i]=m;    cday[i]=day;day++;
	if(m==0||m==2||m==4||m==6||m==7||m==9)
		{if(day==32)
		{m++;day=1;}
		}
	if(m==3||m==8||m==10||m==5)
		{if(day==31){m++;day=1;}}
	if(m==1&&leap==TRUE)
		{if(day==30){m++;day=1;}}
	if(m==1&&leap==FALSE)
		{if(day==29){m++;day=1;}}

	if(m==11&&day==32)
		{break;}
if(week>6)
{week-=7;}





if(week<0)
{week+=7;}
cweek[i]=week;
week++;i++;
}
/*
writestring(mrow,SC+4,label_month[month],BLUE+GREEN);

gotoxy(yrow,SC+1);
textattr(BLUE+GREEN);
cprintf("%d",year);
textattr(BLUE+GREEN);
gotoxy(SR-1,SC);
cprintf(" S   M   T   W   T   F   S  ");
j=0;*/
	for(i=0;i<=365;i++)
	{
	printf("%d %d %d ",cday[i],cweek[i],cmonth[i]);

	}
getch();
}
for the time being kindly ignore the codes inside comment.......
this wont show the expected calender
Last edited on
This makes me weep inside.
It's hard to understand your code. But...wow! It's the old C language.
OMG... Look at the first line of code!!! o.O
It's just a bit long (:))). But where are the headers??
I imagine this is what you get when you code in Notepad with word wrap active.
One thing I'd recommend (I say this over and over again to new programmers) is to split your program up into separate functions. It makes it so much easier for others to read, as well as making it easy to fix.
i am extremely sorry for the complexity of my code and apoplogize the problem created thus to anyone reading it......... and its very less understandability.. ................. i would try my best to make it simpler to comprehend..................
my program is all about creating a calender as in the windows clock , with the month and year determined by the programmer........(for the time being)..................
once again im sorry for the inconvenience caused of any sort..........
Topic archived. No new replies allowed.