Saturday, September 29, 2018

Find the absolute value of a number entered by the user in C++?

#include<iostream.h>
#include<stdio.h>
#include<conio.h> 
int main() 
{
 int a;
 cout<<"Enter any number:";
 cin>>a;

 if(a>0)
  cout<<"The absolute value of number is:"<<a;
 else
  cout<<"The absolute value of number is:"<<-(a);


 return 0;
}

No comments:

Post a Comment