ahmed0saber

Return the positive value in C++

Nov 12th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.17 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int x;
  6.     cout<<"Enter a number : ";
  7.     cin>>x;
  8.     if (x<0)
  9.     {
  10.         x=-x;
  11.     }
  12.     cout<<"The positive value : "<<x;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment