Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. int main() {
  5.  
  6. std::string name;
  7. int age;
  8.  
  9. time_t t = time(NULL);
  10. tm* timePtr = localtime(&t);
  11.  
  12. std::cout << "What is your name? \n";
  13. std::getline(std::cin, name);
  14. std::cout << "What is your age? \n";
  15. std::cin >> age;
  16.  
  17. std::cout << "\nHello, " << name << "!" << std::endl;
  18. std::cout << "Born: " << timePtr->tm_year + 1900 - age << std::endl;
  19. std::cout << 100 - age << " years left until age 100" << std::endl;
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement