Advertisement
Guest User

code1

a guest
Oct 6th, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. int D1;
  7. int D2;
  8. int D3;
  9. int M1;
  10. int M2;
  11. int M3;
  12. int Y1;
  13. int Y2;
  14. int Y3;
  15. int G;
  16. int L=0;
  17. int Valid=1;
  18. cout<<"Age Calculator\n";
  19.  
  20. do
  21. {
  22. cout<<"\n Enter the date of the birth (DD MM YYYY): ";
  23.  
  24. cin>> D1;
  25. cin>> M1;
  26. cin>> Y1;
  27. if (M1==1 || M1==3 || M1==5 || M1==7 || M1==9 || M1==11)
  28. int L=31;
  29.  
  30. if (M1==4 || M1==6 || M1==8 || M1==10 || M1==12)
  31. int L=30;
  32.  
  33. if (M1==2)
  34. int L=29;
  35.  
  36. if (D1<1 || D1>L)
  37. {
  38. cout<<"InValid Date. Enter Again"<<endl;
  39. int Valid=0;
  40. }
  41.  
  42. else if (M1<1 || M1>12)
  43. {
  44. cout<<"InValid Date. Enter Again"<<endl;
  45. int Valid=0;
  46. }
  47.  
  48. else if (Y1<0 || Y1>2011)
  49. {
  50. cout<<"InValid Date. Enter Again"<<endl;
  51. int Valid=0;
  52. }
  53.  
  54. } while (Valid=0);
  55.  
  56.  
  57. cout<<"\n Enter second day of the month (01-31): ";
  58.  
  59. cin>> D2;
  60.  
  61. cout<<"\n Enter second month: ";
  62.  
  63. cin>> M2;
  64.  
  65. cout<<"\n Enter the second year: ";
  66.  
  67. cin>> Y2;
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement