Write an algorithm, to enter two integers and find absolute difference.

 



C++ (TurboC)
#include <iostream.h>
#include<conio.h>
void main()
{
        int n1,n2; //integer data type
        clrscr();
        cout<<“Enter the value of n1 and n2 :”;
        cin>>n1>>n2;
    
    if(n1>n2)
{
        cout<<“ Absolute Difference is :”<<n1-n2;
}
    else
{
        cout<<“ Absolute Difference is :”<<n2-n1;
}
    getch();
}

Post a Comment

0 Comments