C++ program to find the absolute value of a number.


Absolute value means only how far a number is from zero.
or we can say, absolute value of a=|a|
c++ code



#include <iostream.h> #include <math.h> void main() { int a; cout<<"Enter number : "; cin>>a; cout<<"\nAbsolute value = "<<sqrt(a*a); 
//OR use - cout<<"\n"<<fabs(a); }


OUTPUT-
Enter number :-3
Absolute value =3

Comments :

Post a Comment