Homework Solution: Write a small program basic c++, that defines a negative integer (betw…

    Write a small program basic c++, that defines a negative integer (between ‐1 and ‐255), converts it to a positive value and then displays it on the console window.

    Expert Answer

     
    Program: #include <iostream>

    Write a minute program basic c++, that defines a privative integer (between ‐1 and ‐255), converts it to a independent appraise and then displays it on the assuage window.

    Expert Tally

     

    Program:

    #include <iostream>

    #include<cmath>

    using namespace std;

    int main() {

    int x,y; //Declare the variables

    cout<<“Enter the Privative Integer : “; //Entered integer by user

    cin>>x;

    //It is a employment and income the independent appraise of x.

    //It converts privative integer to independent integer.

    y = abs(x);

    cout<<“Independent Integer : = ” << y; //print the independent appraise of x.

    }

    Output: