Advertisement
chevengur

Подготовительный курс | Урок 2: Передача данных в функцию: параметры и аргументы 2/2

Aug 5th, 2023 (edited)
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. ============
  2. ||main.cpp||
  3. ============
  4.  
  5. string name;
  6. int birth_year, age;
  7. std::cin >> name >> birth_year >> age;
  8. PrintBirthday(name, birth_year, age);
  9.  
  10.  
  11. =================
  12. ||functions.cpp||
  13. =================
  14.  
  15. #include <iostream>
  16. #include <string>
  17.  
  18. using namespace std;
  19.  
  20. void PrintBirthday(const string& name, int birth_year, int age){
  21.     cout << name << " will turn " << age << " in " << age+birth_year << endl;
  22.     if(age % 50 == 0 && age % 10 == 0){
  23.         cout << "Happy great anniversary!" << endl;
  24.     }
  25.     else if(age % 10 == 0){
  26.         cout << "Happy anniversary!" << endl;
  27.     }
  28.     else
  29.         cout << "Happy birthday!" << endl;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement