Absolute difference
// the absolute difference will be |a-b|;
M1>
int a,b;cin>>a>>b;
e=(a>b)?(a-b):(b-a);
cout<<e;
M2>
#include<cstdlib> //this Headerfile must be included in the file
int a,b;
cin>>a>>b;
e=abs(a-b); //the inbuilt func. to find absolute difference
cout<<e;
MM
Comments
Post a Comment