Advertisement
chevengur

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

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