Advertisement
Josif_tepe

Untitled

Mar 10th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int absolute_value(int a) {
  6.     if(a < 0) {
  7.         return a * (-1);
  8.     }
  9.     else {
  10.         return a;
  11.     }
  12. }
  13. int main()
  14. {
  15.     int n;
  16.     cin >> n;
  17.     cout << absolute_value(n) << endl;
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement