Wednesday, May 12, 2010

How to find number of days and difference between to dates using C


int count=-1,nofdays=-1,nofmonths=-1,nofyears=-1,lastmonthmaxday;
int main()
{
printf("This program will ask for two date values in the formate of DD-MM-YYYY and produces the number of days between the two dates also if those dates are your birth date and some later date then it will display your age till the later date.This will not validate for any wrong entry for days(like more than 30-31) and months(like more than 12).However if you enter,you will get some unexpected result. If you need, with a few changes and little affords you can achieve your requirements.\n");
int day1,day2,month1,month2,year1,year2,day11,month11,year11,year,month,day,maxdays,flag=0;
static int z=1;
printf("Enter the privous date (DD) \n");
scanf("%d",&day1);
printf("Enter the privous month (MM) \n");
scanf("%d",&month1);
printf("Enter the privous year,for not being ambiguous input plz enter in YYYY format,else it will be a y2k bug\n");
scanf("%d",&year1);
printf("Enter the later date (DD)\n");
scanf("%d",&day2);
printf("Enter the later month (DD)\n");
scanf("%d",&month2);
printf("Enter the later year,for not being ambiguous input plz enter in YYYY format,else it will be a y2k bug\n");
scanf("%d",&year2);
day11=day1;month11=month1;year11=year1;lastmonthmaxday=checkmonth(month2-1,year2);
for(year=year11;year<=year2;year++) { for(month=month11;month<=12;month++) { if(year==year2 && month==month2) { flag=0;lastmonthmaxday=day2;countday(day11,day2,flag); break; } else { maxdays=checkmonth(month,year); countday(day11,maxdays,flag);flag=1;day11=1; } } month11=1; nofyears++; } if(month2<=month1 && nofyears !=0) { --nofyears; } if((day2<=day1 && nofmonths !=0) || nofmonths==12 ) { if(nofmonths==12){ nofyears++; nofmonths=0; } else --nofmonths; } maxdays=checkmonth(month2-1,year2); if(nofdays>=maxdays)
nofdays=nofdays-maxdays;
printf("The total number of days are : %d \nYou are %d year %d months %d days older\n",count,nofyears,nofmonths,nofdays);
return 0;
}
//This function will start from the previous date and keep on counting each day as long as it come to the later date.
void countday(int ddin, int ddfnl,int flg)
{
int i,day1,day2=35;
static int x=1,y=1;
for(i=ddin;i<=ddfnl;i++) { count++; if(flg==0 && i<=lastmonthmaxday) { if(lastmonthmaxday>ddfnl && x==1)
{
nofdays=nofdays+(lastmonthmaxday-ddfnl);
x++;
}
nofdays++;
if(y==1)
day1=ddin;
else if(y==2)
day2=ddfnl;
y++;
if(day1>day2)
{
break;
}
}
}
nofmonths++;
if(nofmonths==13)
nofmonths=1;
}
int checkmonth(int month,int year)
{
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12 || month==0) //These are the months having 31 days
return 31;
else if(month==4 || month==6 || month==9 || month==11) //These are the months having 30 days
return 30;
else if(month==2) //This is for february only
{
if((year%400==0) || (year%4==0 && year%100!=0)) //This is for checking a leap year
return 29;
else
return 28;
}
}





Delicious add to del.icio.us saved by 0 users

Sunday, May 9, 2010

How Peter Answers Virtual Tarot works?


Well!! You are amazed that how one of your friends told you to sit beside him and he opened a website http://www.peteranswers.com/ and your friend had started asking questions about you to Mr. Peter and Mr. Peter started answering correctly(sometimes answer to your very personal questions too), isn’t it? You want to know the story behind this. How Peter knows all about every thing, every one? Ok then listen carefully.

Actually Peter (1957-1979) was a software Engineer fully devoted and addicted of computers and programming. One day he designed a software application which can directly connect to his brain and his soul. The software can tell each and every thing what was there in his mind. What ever he thought, the software could tell. He finally decided to donate this software to US army for the sake of helping humanity. But somehow a terrorist came to know about this. Peter was about to leave to meet Mr. President. A gunman came in front of him as he came out of his house and asked him to give the software. He denied. The gunman threatened him to kill him. But he did not give. The gunman finally put the barrel of the gun on his forehead and asked for the last time. But you know, Peter was very brave and he denied once again. And the gunman pulled the trigger. Peter fell down and died in few seconds. But you know one thing. The software was still connected to his brain. You know one thing the daring and brilliant software programmer had all ready uploaded that software to http://www.peteranswers.com/. His sole is still alive in this world and his brain is working, collecting information about each and everything. And this application is answering to every question today also. If you do not ask him politely he will become angry and he will not answer to your question. He answers to only those people who know his story and who asks question politely. Now you know every thing about him so he will answer to your questions.



Was the story good? So can I tell you the truth now? Ok!! There is a trick. In the petition box what ever you write, will come as an output. Amazed again!! You have to follow these simple steps. Call a friend and tell Mr. Peter’s story first. Then tell him to ask a question to Mr. Peter politely. The answer to that question must be known to you. Step 1: Click in the Petition box (now the cursor is blinking in the box). Step 2: Press dot (.) as the first key, as soon as you press (.) at the same time ‘P’ will appear in the box automatically(in Petition Box). Step 3: Now write the answer to the question for your friend. As you write the answer, the box will automatically show “Peter, please answer the following question” irrespective of what you type (What you type here will come as an output so write correctly). If the answer is small you can press space bar to complete the sentence (“Peter, please answer:”). Step 4: Press enter. The cursor will now be blinking in the Question box. Step 5: Write your friends question and press enter. If this is you first time then a message box will come to accept the terms. Press ok and fool your friends. Ok. Enjoy.





Delicious add to del.icio.us saved by 0 users

Saturday, May 8, 2010

Funny and Amazing Pictures















Delicious add to del.icio.us saved by 0 users

The A - Z of Friendship





Friends are like Stars .. you can't always see them, but you know they're always there.
















Delicious add to del.icio.us saved by 0 users

The City Beautiful, Chandigarh, India


Chandigarh is aliased as The City Beautiful and it deserve to be. I knew this when I lived in Chandigarh for one month from Jan-10 to Feb-10 and it was a good experience. I have gone to many cities in India but I have never seen a city as well arranged as Chandigarh. The beauty is that every house in Chandigarh is of same structure and in a row. Chandigarh is divided in to many sectors starting from sector 1 to some sector 52-53. Each sector is having a residential area starting from A-D like 17C. Each residential sector is having its own market. There are two ISBT (Inter State Bus Terminus). One is in Sector 17(For Shimla, Ambala, Sonipath, Delhi route) and other is in sector 43(for Ludhiana, Amritsar, Jammu route). The city is very clean and roads are very nice. There are trees on the both side of the road. There is a separate track for walking people, cycles and rickshaws. One amazing thing, you know, there is not even a single flyover in the city but in spite of that you will never face traffic problem in the city. For this you have to praise the awesome traffic system of Chandigarh. This city has been ranked the best city to live in, by many magazines. The standard of living of this city is very high and as a result living in this city is little bit costly. Most of the people in Chandigarh are government employees, businessmen, or NRIs. All are rich.And no one is miser. You can see almost all luxurious cars there. Audi and Mercedes are common. Every body is having costly handsets and other gadgets. People of Chandigarh are very fashionable. They wear according to the current fashion. No simple hair style and beards will be visible. The city also attracts the drunkards because they can get Beer by spending ½ of bucks then what they pay in other cities. Whiskies, Scorch, Rum and other alcoholic liquid drinks are sometimes more cheaper ( ½ of cost or even less what you pay in other cities). I will rate this city as 9/10 in all aspects.



Delicious add to del.icio.us saved by 0 users

 

Never feel bad if u loose some thing or do not get expected because "There is always a better option"