View Single Post
Join Date: Jul 2008
Posts: 41
Reputation: raja289 is an unknown quantity at this point 
Solved Threads: 0
raja289 raja289 is offline Offline
Light Poster

need urgent responce please!

 
0
  #1
Dec 1st, 2008
i am designing a code that will calculate tomorrows date but there is some problem with the code,
when i enter
year = 2008 or anyother
month =12
day = 31
it gives tmorrows date as 1/2/2008
please help and tell me if i can do more improvements thanks
  1. #include<conio.h>
  2. #include<stdio.h>
  3. main(void)
  4. {
  5. int t;
  6. int y,d=1,i,m=1;
  7. printf("Enter the Year: ");
  8. scanf("%4u",&y);
  9. if(y<0)
  10. y=-y;
  11. printf("Enter the Month: ");
  12. scanf("%2u",&m);
  13. if(m<=0 || m>=12)
  14. m=1;
  15. i=y%4;
  16. printf("Enter the Day: ");
  17. scanf("%2u",&d);
  18. if (d>=1&&d<28)
  19. d=d+1;
  20. else if(d==i&&m==2)
  21. {d=1;
  22. m=3;}
  23. else if (d==30&&m==4||m==6||m==9||m==11)
  24. {d=1;
  25. m=m+1;}
  26. else if (d==31&&m==1||m==2||m==3||m==5||m==7||m==8||m==10)
  27. {
  28. d=1;
  29. m=m+1;
  30. }
  31. else if(d==31&&m==12)
  32. {
  33. d=1;
  34. m=1;
  35. y=y+1;
  36. }
  37. printf("Tomorrow's Date is\n %d/%d/%d ",d,m,y);
  38. getch();
  39. }
Reply With Quote