Tuesday, 24 December 2013

Find the absolute value of a number entered through the keyboard. (c++ code)

#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
  int i, j;
  cout<<"Enter a nagtive (-ve) number : ";
  cin>>i;
  if(i<0)
    j = -i;
  else
    j = i;
  cout<<j; 
  getch();
  return 0;

  /*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
return 0;
}

No comments:

Post a Comment