RedChu

Pseudo-Code: get_age()

Apr 21st, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // pseudo-code function for grabbing the years elapsed
  2. // from the day, month and year given
  3. // probably not the most efficient way to do it but it works
  4.  
  5. get_age()
  6. {
  7. day = 1;
  8. month = 5;
  9. year = 1992;
  10.  
  11. age = 0;
  12.  
  13. for(i = year; i < current_year; i++)
  14. {
  15. age++;
  16. }
  17.  
  18. if(month > current_month)
  19. {
  20. age--;
  21. }
  22. elseif(month == current_month)
  23. {
  24. if(day > current_day)
  25. {
  26. age--;
  27. }
  28. }
  29.  
  30. return age;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment