Advertisement
adnanj

Je li broj paran/neparan i pozitivan/negativan?

Dec 11th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool paran(int);
  5. bool pozitivan(int);
  6.  
  7. int main()
  8. {
  9.     int broj;
  10.  
  11.     cout << "Unesite cijeli broj: ";
  12.     cin >> broj;
  13.  
  14.     if (paran(broj))
  15.     cout << "Broj je paran i ";
  16.     else
  17.     cout << "Broj je neparan i ";
  18.    
  19.     if (pozitivan(broj))
  20.     cout << " pozitivan!";
  21.     else
  22.     cout << " negativan!";
  23.  
  24.     system ("pause>0");
  25.     return 0;
  26. }
  27.  
  28. bool paran(int x)
  29. {
  30.     if (x%2==0)
  31.     return 1;
  32.     return 0;
  33. }
  34.  
  35. bool pozitivan(int y)
  36. {
  37.     if (y>0)
  38.     return 1;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement