Hello, I am trying to write up a calendar with no luck. Well, I am trying to test "calcJanFirst", but when I type in the year and send it to calcJanFirst I alway get the same number. No matter what year I put in. I believe I am sending the value incorrectly to calcJanFirst. Can someone check what i'm doing wrong please. Thank you. -
/*
-
Print Calendar
-
-
*/
-
-
#include <stdio.h>
-
-
// Function Declarations
-
int getYear ( void );
-
int calcJanFirst ( int year );
-
void printCalendar( int year, int JanFirst );
-
-
int chooseDays ( int year, int month );
-
int isLeap ( int year );
-
-
void printHeader ( int year, int month );
-
int printMonth ( int firstDay, int days );
-
-
int main( void )
-
{
-
// Local Declarations
-
int year, month,firstday,JanFirst;
-
-
// Statements
-
getYear();
-
-
-
//printMonth(2, 29); // starting date and ending dates
-
calcJanFirst(JanFirst);
-
-
-
-
return 0;
-
}
-
-
-
-
/* ======================================================= */
-
/* This function prompts the user to enter a year: if it is
-
within the range 1000 to 3000 it is considered a valid year;
-
otherwise, it prompts the user to enter another value, until
-
it is valid.
-
PRE : nothing
-
POST: year is returned
-
*/
-
int getYear (void)
-
{
-
// Local Declarations
-
int year;
-
// Statements
-
-
printf("Please enter a year between 1000 to 3000\n");
-
scanf("%d",&year);
-
-
if(!(year >=1000) || !(year <=3000))
-
{
-
while(year<1000 || year>3000)
-
{
-
printf("Please enter a year between 1000 to 3000\n");
-
scanf("%d\n",&year);
-
}
-
-
}
-
return year;
-
}
-
-
/* ======================================================= */
-
/* This function determines the day of the week for
-
January first: 0 - Sunday, 1 - Monday, ... 6 - Saturday.
-
- see formula at page 388
-
PRE : year
-
POST: day of the week for Jan 1st returned
-
-
*/
-
int calcJanFirst ( int year )
-
{
-
int JanFirst;
-
-
JanFirst = (((year - 1 ) * 365) + ((year - 1) % 4) - ((year - 1) % 100) +
-
((year - 1) %400)+1)%7;
-
-
printf("testing calcJanFirst %d",JanFirst);
-
return JanFirst;
-
}
-
-
1 1247
1) I think you should save the resuklt of getYear (I'd use year rather than JanFirst....
2) I think you should pass this result to calcJanFirst
viz -
int main (void) //if you like
-
{
-
int year, month, JanFirst; //etc
-
year = getYear(); /this is why we have the year variable I would assume
-
JanFirst = calcJanFirst(year);
-
printf("The year is %d and JanFirst is %d", year, JanFirast);
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Shelly |
last post by:
Hi all
I require a calendar control in .NET in Japanese. But how do I convert this
into the year convention followed in Japan, as I understand that it is
different from ours??
Please help me...
|
by: Shuffs |
last post by:
Could someone, anyone please tell me what I need to amend, to get this
function to take Sunday as the first day of the week?
I amended the Weekday parts to vbSunday (in my code, not the code...
|
by: Shyguy |
last post by:
Is it possible to create a calendar that shows previous input data and
also allows for input of new data?
|
by: Jeff S |
last post by:
I would like recommendations for implementing a calendar in an ASP.NET web
site. My plan is to store date and event information (e.g,, "Spring Sale")
in a database, and when the page is requested,...
|
by: R.A.M. |
last post by:
Hello,
I need to implement popup calendar in ASP.NET application. I created a
button opening popup calendar on 'master' page:
<asp:Button ID="Calendar" runat="server"
Text=Calendar"...
|
by: larry |
last post by:
I am in the process of rewriting one of my first PHP scripts, an event
calendar, and wanted to share the code that is the core of the new
calendar. My current/previous calendar processed data...
|
by: gubbachchi |
last post by:
Hi all,
Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
|
by: sbettadpur |
last post by:
hello everybody,
i am using readymade popup calendar for my application, it's working fine.
But i am facing some problem i.e. if i click on the calendar image it will open a calendar. below...
|
by: juanmorero |
last post by:
When I attempt to create a call plan in the Calendar screen and I'm trying to drag the contact to the Calendar applet. After that, I tried to click on the hyperlink in the calendar applet so as to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |