Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gürcan Güleç
/
iag0581
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
be0f0170
authored
Oct 22, 2016
by
Gürcan Güleç
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing calendar.c
parent
339b27f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
labs/lab4/calendar.c
labs/lab4/calendar.c
View file @
be0f0170
...
@@ -17,7 +17,15 @@ int main()
...
@@ -17,7 +17,15 @@ int main()
int
leap
=
0
;
int
leap
=
0
;
int
m1
[
7
]
=
{
1
,
3
,
5
,
7
,
8
,
10
,
12
};
int
m1
[
7
]
=
{
1
,
3
,
5
,
7
,
8
,
10
,
12
};
printf
(
"Enter a date(DDMMYYY): "
);
scanf
(
"%d"
,
&
date
);
scanf
(
"%d"
,
&
date
);
if
(
date
<
0
)
{
printf
(
"Date cannot be minus: "
);
scanf
(
"%d"
,
&
date
);
}
// finding the year
// finding the year
int
year
=
date
%
10000
;
int
year
=
date
%
10000
;
...
@@ -31,8 +39,14 @@ int main()
...
@@ -31,8 +39,14 @@ int main()
printf
(
"Month = %d
\n
"
,
month
);
printf
(
"Month = %d
\n
"
,
month
);
printf
(
"Year = %d
\n
"
,
year
);
printf
(
"Year = %d
\n
"
,
year
);
if
(
date
<=
0
)
{
printf
(
"Date not valid
\n
"
);
return
0
;
}
// month cannot be bigger than 12
// month cannot be bigger than 12
if
(
month
>
12
)
if
(
month
>
12
||
month
<=
0
)
{
{
printf
(
"Date not valid
\n
"
);
printf
(
"Date not valid
\n
"
);
return
0
;
return
0
;
...
@@ -89,7 +103,7 @@ int main()
...
@@ -89,7 +103,7 @@ int main()
{
{
if
(
leap
==
1
)
if
(
leap
==
1
)
{
{
if
(
day
!=
29
)
if
(
day
>
29
)
{
{
printf
(
"Date not valid
\n
"
);
printf
(
"Date not valid
\n
"
);
return
0
;
return
0
;
...
@@ -97,7 +111,7 @@ int main()
...
@@ -97,7 +111,7 @@ int main()
}
}
else
else
{
{
if
(
day
!=
28
)
if
(
day
>
28
)
{
{
printf
(
"Date not valid
\n
"
);
printf
(
"Date not valid
\n
"
);
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment