MeehoweCK

Untitled

Mar 19th, 2021
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int wiek;
  8.     cout << "Napisz ile masz lat: ";
  9.     cin >> wiek;
  10.     if(cin.fail())      // cin.fail() zwraca prawdę (true) jeżeli wystąpił błąd w buforze wejścia
  11.         cout << "Podales niepoprawna liczbe!\n";
  12.     else
  13.         cout << "Masz " << wiek << " lat\n";
  14.  
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment