Sunday, 15 June 2014

C++ program to find absolute value of a given number



Here is a C++ program to find absolute value of a given number


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int num,num1;
    cout<<"Enter number ";
    cin>>num;
    num1=num;
    if(num<0)
        num=-num;
    cout<<"Absolute value of "<<num1<<" = "<<num;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment