+ 1

how do i make this code display the answer in positive (+) even if the answer is in negative.

#include <iostream> using namespace std; int a=4; int b=10; cout<<a-b; // I know the real answer is -6 but I want the answer displayed in positive(+). How do I do it?//

14th Jan 2017, 3:57 PM
Cody Arthur
Cody Arthur - avatar
2 ответов
+ 7
#include <cmath> cout<<abs(a-b);
14th Jan 2017, 4:00 PM
Filip
Filip - avatar
+ 2
cout <<abs (a-b) import cmath file
14th Jan 2017, 4:02 PM
ASNM
ASNM - avatar