C program to create calendar
Note: that there is no input checking or error handling is performed to keep things simple. The next function determinedaycode is used to get the day number of the first day in that year, so we can print the date on the correct position. So it is only used for output purposes. The next function determineleapyear is used to determine if input of the user is a leap year. If so, the number if days in February is changed to The last function calendar is used to print each month onto the screen.
The first for loop is used to loop through all months. We then use the daycode to position the prompt under the right weekday. Then we print all the dates for one month. The last thing we do is to set the position of the prompt on the right weekday. Can anyone help me?
On my last post the months February and April should been a few spaces foward like the week day. Am trying to develop a program to output the date on requesting for a 30 days leave and when the leave will end.
But it is not working out. If you want to get all the all the dates for a particular day of the week in a chosen month you can do something like this;. You would have to ask the user to enter a day of the week and set weekDay to the value they enter. I haven't fully tested this though so be careful - This would have to be entered into your FillCalendar method.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. C - write a program that displays the calendar, asking just for the year and month, use System. DateTime [closed] Ask Question. Asked 5 years, 1 month ago. Active 5 years, 1 month ago. Viewed 9k times. If none of the conditions met, break; statement will be executed and program flow will proceed.
Note: Afer every validation failure message continue; statement is written to make sure that the rest of the codes within the loop are not executed. Before we proceed with the remaining part of the main method, let's declare some constant and write the required functions.
Here wehave declared three arrays. MonthDay[] will be used to determine the number of days in a month. We will handle Leap Year separately. In our case, we have not provided number of rows as we have initialized the array with values at the time of declaration only.
Zeller's Algorithm can be used to determine the day of the week for any date in the past, present or future, for any dates between and We're using this function to get the weekday of the 1st day of given month.
We'll be using this function to catch user input, like, left-arrow key, right-arrow-key, up-arrow key, down-arrow key, I, P, etc. This function will be used to do some formatting the output. PrintFile ; - function will be used to print the output in a text file and save in the disk.
Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. What's New. Most popular in C Language. We use cookies to ensure you have the best browsing experience on our website.
0コメント