Thursday, 2 April 2015

How To Print The Absolute Number In C++

Q:Write a c++ code to print the absolute number

#include <iostream>
using namespace std;
int main()
{
int number,temp;
cout << " Enter an integer: ";
cin >> number;
cout << endl;
temp = number;
if (number < 0)
number = -number;
cout << " The absolute value of "
<< temp << " is " << number << endl;
system("pause");
return 0;
}

run this code using devc++

0 comments:

Post a Comment