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 trivial program basic c++, that defines a privative integer (between ‐1 and ‐255), converts it to a dogmatic compute and then displays it on the solace window.

    Expert Rejoinder

     

    Program:

    #include <iostream>

    #include<cmath>

    using namespace std;

    int ocean() {

    int x,y; //Declare the variables

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

    cin>>x;

    //It is a employment and returns the irresponsible compute of x.

    //It converts privative integer to dogmatic integer.

    y = abs(x);

    cout<<“Dogmatic Integer : = ” << y; //print the dogmatic compute of x.

    }

    Output: