Forums.Sureshkumar.net : A Perfect Place to Share Knowledg Blogs   Games  Magazines   click here

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > Interview Questions > Interview Questions > C
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

C C Interview Questions asked in various Interviews. Professionals are invited to share Answers for these C Interview Questions. C Interview Questions with answers, Experiences, Career Advices, Tips and more.

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 14-06-08, 01:53 AM   #1 (permalink)
Senior Member
 
Join Date: Apr 2008
Posts: 13,563
Thanks: 0
Thanked 9 Times in 9 Posts
Thanks: 0
Thanked 9 Times in 9 Posts
Rep Power: 137 ShivaniX is on a distinguished road ShivaniX is on a distinguished road
Does C have any Year 2000 problems



Does C have any Year 2000 problems?

ShivaniX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 29-10-08, 02:06 PM   #2 (permalink)
Junior Member
 
Join Date: Oct 2008
Age: 24
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks: 2
Thanked 0 Times in 0 Posts
Rep Power: 1 retheeshsoman is on a distinguished road
Re: Does C have any Year 2000 problems

Dear Sivani,
No, The actual rules for the present Gregorian calendar are that leap years occur every four years, but not every 100 years, except that they do occur every 400 years, after all. In C, these rules can be expressed as:
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
Actually, if the domain of interest is limited (perhaps by the range of a time_t) such that the only century year it encompasses is 2000, the expression
(year % 4 == 0) /* 1901-2099 only */
is accurate, if less than robust.
If you trust the implementor of the C library, you can use mktime to determine whether a given year is a leap year;
Note also that the transition from the Julian to the Gregorian calendar involved deleting several days to make up for accumulated errors. (The transition was first made in Catholic countries under Pope Gregory XIII in October, 1582, and involved deleting 10 days. In the British Empire, eleven days were deleted when the Gregorian calendar was adopted in September 1752. A few countries didn't switch until the 20th century.) Calendar code which has to work for historical dates must therefore be especially careful.

eg: Write a program to find whether an year is leap or not?
int leap(int year){
if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
return 1;
else
return 0;
}
int main(){
int year;
printf("Enter Year ?\n");
scanf("%d",&year);
if(leap(year))
printf("Leap Year \n");
else
printf("Non Leap \n");
}

output:
Enter Year ?
2000
Leap Year

Enter Year ?
2001
Non Leap


retheeshsoman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
c language , interview questions



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Inspired With The 17 Year Old CEO... vjsreevs Inspire yourself & Others - Leaders Zone 3 10-12-08 11:52 PM
specialty of this NEW year AjayKumar.Kataram FRIENDSHIP & LOVE 1 02-01-07 11:34 AM
some recent major computer system failures caused by software bugs AjayKumar.Kataram Latest Tech News & Innovations 2 21-12-06 05:06 PM
What are 5 common problems in the software development process? das.testing Testing Tools & QA 0 10-11-06 10:56 PM
System Administrator Experience 0 year- 1 year sridhar FRESHER JOBS 3 05-09-06 09:33 PM


All times are GMT +6.5. The time now is 06:30 PM.




Get Short Listed Fast !! Upload Your CV here & Apply New Jobs Everyday.

Search Engine Optimization by vBSEO 3.1.0